Debian – matoken's blog https://matoken.org/blog Is there no plan B? Mon, 14 Oct 2024 22:39:35 +0000 ja hourly 1 https://wordpress.org/?v=6.8.3 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg Debian – matoken's blog https://matoken.org/blog 32 32 DebianをParrotOSに変換してみる https://matoken.org/blog/2024/10/15/converting-debian-to-parrotos/ https://matoken.org/blog/2024/10/15/converting-debian-to-parrotos/#respond Mon, 14 Oct 2024 22:39:32 +0000 https://matoken.org/blog/?p=4135

Debian から ParrotOS に変換する Debian Conversion Script を試してみました.

ParrotOS のダウンロードページでいろいろな選択肢があるなと見ていると,

Choose the right edition for you
Follow the steps below to determine the edition of ParrotOS that best suits your needs and preferences.

Debian Conversion Script というのを見かけて試してみました.

Debian Conversion Script

Quick script to convert an existing Debian installation to Parrot (all editions).

まず Debian stable 12.7.0 を netinst iso(debian-12.7.0-amd64-netinst.iso)から導入して起動しました.

そしてこちらのリポジトリの script を利用します.

初期状態では入っていない git を導入して clone,インストールスクリプトに実行権を付けて実行します.

$ sudo apt install git
$ git clone https://gitlab.com/parrotsec/project/debian-conversion-script.git
$ cd debian-conversion-script
$ sudo chmod +x ./install.sh
$ script
$ sudo ./install.sh

以下のような選択肢が出てくるので好みの Edition を選択します.今回はまず 2 のデスクトップの日常用途を選びました.

========== ParrotOS Editions Installer ==========
1) Install Core Edition: Minimal installation for server use.
2) Install Home Edition: Full desktop environment for daily use.
3) Install Security Edition: Tools for security testing and auditing.
4) Install Hack The Box Edition: Customized environment for Hack The Box labs.
5) Install Headless Edition: Minimal installation without GUI for servers.
6) Exit
=================================================
Enter the option number: 2

しばらく待つと導入されるので再起動して ParrotOS になっているのを確認します.
Xfce でしたが,MATE になり壁紙なども Parrot に.Home Edition だとアプリケーションなどはあまり変わらなそうです.パッケージリストは ./config/packages/ 以下に Edition ごとに置いてあります.

parrotos
parrotos neofetch

という感じで簡単に ParrotOS になりました.再度インストール script を実行して他の Edition を選択し直すこともできました.

Debian でも forensics-* あたりの metapackage を入れれば良いのではと思ったりしますがしばらく ParrotOS も試してみようと思います.

$ apt-cache search ^forensic
foremost - forensic program to recover lost files
forensic-artifacts - knowledge base of forensic artifacts (data files)
forensics-all - Debian Forensics Environment - essential components (metapackage)
forensics-all-gui - Debian Forensics Environment - GUI components (metapackage)
forensics-colorize - show differences between files using color graphics
forensics-extra - Forensics Environment - extra console components (metapackage)
forensics-extra-gui - Forensics Environment - extra GUI components (metapackage)
forensics-full - Full forensics station (metapackage)
forensics-samples-all - Set of files to help learn/test forensics tools and techniques (metapackage)
forensics-samples-btrfs - Set of files to help learn/test forensics tools and techniques (btrfs)
forensics-samples-exfat - Set of files to help learn/test forensics tools and techniques (exFAT)
forensics-samples-ext2 - Set of files to help learn/test forensics tools and techniques (ext2)
forensics-samples-ext4 - Set of files to help learn/test forensics tools and techniques (ext4)
forensics-samples-files - Set of files to help learn/test forensics tools and techniques (files)
forensics-samples-multiple - Set of files to help learn/test forensics tools and techniques (multiple FS)
forensics-samples-ntfs - Set of files to help learn/test forensics tools and techniques (ntfs)
forensics-samples-tools - Set of files to help learn/test forensics tools and techniques (tools)
forensics-samples-vfat - Set of files to help learn/test forensics tools and techniques (vfat)
guymager - Forensic imaging tool based on Qt
unhide - forensic tool to find hidden processes and ports
unhide.rb - Forensics tool to find processes hidden by rootkits
vinetto - forensics tool to examine Thumbs.db files
]]>
https://matoken.org/blog/2024/10/15/converting-debian-to-parrotos/feed/ 0
Debian testing の source.list に non-free-firmware を登録 https://matoken.org/blog/2023/02/02/debian-testing-source-list-non-free-firmware/ https://matoken.org/blog/2023/02/02/debian-testing-source-list-non-free-firmware/#respond Thu, 02 Feb 2023 11:14:59 +0000 https://matoken.org/blog/?p=3835

Debian で non-free-firmware というコンポーネントが増えることになり,実際に移動し始めたとのことで利用できるように設定しました.

/etc/apt/sources.list を編集します.直に編集することも出来ますが, apt edit-sources を使うと保存時に文法チェックをしてくれるのでおすすめです.

$ sudo apt edit-source
編集例
$ sudo git -C /etc diff /etc/apt/sources.list
diff --git a/apt/sources.list b/apt/sources.list
index d9af843..11f6837 100644
--- a/apt/sources.list
+++ b/apt/sources.list
@@ -2,8 +2,8 @@

 #deb cdrom:[Debian GNU/Linux testing _Bookworm_ - Official Snapshot amd64 DVD Binary-1 20220919-00:24]/ bookworm contrib main

-deb http://deb.debian.org/debian/ bookworm main contrib non-free
-deb-src http://deb.debian.org/debian/ bookworm main contrib non-free
+deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
+deb-src http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
 #deb http://security.debian.org/debian-security bookworm-security main contrib
 #deb-src http://security.debian.org/debian-security bookworm-security main contrib

@@ -13,13 +13,13 @@ deb-src http://deb.debian.org/debian/ bookworm main contrib non-free
 # are provided as examples, but you should amend them as appropriate
 # for your mirror of choice.
 #
-deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free
-deb-src http://deb.debian.org/debian/ bookworm-updates main contrib non-free
+deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware
+deb-src http://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware

 # bookworm-backports, previously on backports.debian.org
 # A network mirror was not selected during install.  The following entries
 # are provided as examples, but you should amend them as appropriate
 # for your mirror of choice.
 #
-deb http://deb.debian.org/debian/ bookworm-backports main contrib non-free
-deb-src http://deb.debian.org/debian/ bookworm-backports main contrib non-free
+deb http://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware
+deb-src http://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware

apt update コマンドでパッケージリストを更新, apt upgrade コマンドでパッケージを最新にします.

$ sudo apt update
$ sudo apt upgrade

早速 non-free-firmware から firmware-iwlwifi が降ってきました.

取得:1 http://deb.debian.org/debian bookworm/non-free-firmware amd64 firmware-iwlwifi all 20221214-5 [20.5 MB]

今回 bookworm(testing) で設定しましたが,sid(unstable) の場合も同様だと思います.

環境
$ lsb_release -a
Distributor ID:	Debian
Description:	Debian GNU/Linux bookworm/sid
Release:	n/a
Codename:	bookworm
$ dpkg-query -W apt dpkg
apt	2.5.5
dpkg	1.21.19
$ arch
x86_64

追記) Bookworm 新規インストールの場合

non-free-firmware が有効になった Debian-Installer Bookworm Alpha 2 が出たので少し試してみました.
パッケージマネージャの設定で,「non-free のファームウェアを使用しますか?」「はい」を選択することで, source.listnon-free-firmware が設定されるのを確認しました.

d i bookworm a2 non free firmware gui
d i bookworm a2 non free firmware cui

]]>
https://matoken.org/blog/2023/02/02/debian-testing-source-list-non-free-firmware/feed/ 0
rmadison でパッケージのバージョンを確認 https://matoken.org/blog/2022/03/03/check-the-package-version-with-rmadison/ https://matoken.org/blog/2022/03/03/check-the-package-version-with-rmadison/#respond Thu, 03 Mar 2022 14:10:32 +0000 http://matoken.org/blog/?p=3504

Twitterで rmadison というコマンドを教えてもらいました.

rmadison はリモートのデータベースにアクセスしてパッケージのバージョン情報を表示してくれるコマンドで,Debianでは devscripts パッケージに含まれています.

$ rmadison --help
Usage: rmadison [OPTION] PACKAGE[...]
Display information about PACKAGE(s).

  -a, --architecture=ARCH    only show info for ARCH(s)
  -b, --binary-type=TYPE     only show info for binary TYPE
  -c, --component=COMPONENT  only show info for COMPONENT(s)
  -g, --greaterorequal       show buildd 'dep-wait pkg >= {highest version}' info
  -G, --greaterthan          show buildd 'dep-wait pkg >> {highest version}' info
  -h, --help                 show this help and exit
  -r, --regex                treat PACKAGE as a regex [not supported everywhere]
  -s, --suite=SUITE          only show info for this suite
  -S, --source-and-binary    show info for the binary children of source pkgs
  -t, --time                 show projectb snapshot date
  -u, --url=URL              use URL instead of debian

  --noconf, --no-conf        don't read devscripts configuration files

ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
    --architecture=m68k,i386

Aliases for URLs:
        debian  https://api.ftp-master.debian.org/madison
        new     https://api.ftp-master.debian.org/madison?s=new
        qa      https://qa.debian.org/madison.php
        ubuntu  https://people.canonical.com/~ubuntu-archive/madison.cgi
        udd     https://qa.debian.org/cgi-bin/madison.cgi

例えば OpenSSH を指定するとこんな感じでtesting以降に 8.9p1 が来ているのが分かります.

a$ rmadison openssh
openssh    | 1:6.7p1-5+deb8u4   | oldoldoldstable        | source
openssh    | 1:7.4p1-10+deb9u7  | oldoldstable           | source
openssh    | 1:7.4p1-10+deb9u7  | oldoldstable-debug     | source
openssh    | 1:7.9p1-10+deb10u2 | oldstable              | source
openssh    | 1:7.9p1-10+deb10u2 | oldstable-debug        | source
openssh    | 1:8.4p1-2~bpo10+1  | buster-backports       | source
openssh    | 1:8.4p1-2~bpo10+1  | buster-backports-debug | source
openssh    | 1:8.4p1-5          | stable                 | source
openssh    | 1:8.8p1-1          | testing                | source
openssh    | 1:8.9p1-3          | unstable               | source
openssh    | 1:8.9p1-3          | unstable-debug         | source

urlを指定することでUbuntuの情報も

$ rmadison -u https://people.canonical.com/~ubuntu-archive/madison.cgi openssh
 openssh | 1:6.6p1-2ubuntu1    | trusty          | source
 openssh | 1:6.6p1-2ubuntu2.13 | trusty-security | source
 openssh | 1:6.6p1-2ubuntu2.13 | trusty-updates  | source
 openssh | 1:7.2p2-4           | xenial          | source
 openssh | 1:7.2p2-4ubuntu2.8  | xenial-security | source
 openssh | 1:7.2p2-4ubuntu2.10 | xenial-updates  | source
 openssh | 1:7.6p1-4           | bionic          | source
 openssh | 1:7.6p1-4ubuntu0.5  | bionic-security | source
 openssh | 1:7.6p1-4ubuntu0.6  | bionic-proposed | source
 openssh | 1:7.6p1-4ubuntu0.6  | bionic-updates  | source
 openssh | 1:8.2p1-4           | focal           | source
 openssh | 1:8.2p1-4ubuntu0.2  | focal-security  | source
 openssh | 1:8.2p1-4ubuntu0.4  | focal-updates   | source
 openssh | 1:8.4p1-6ubuntu2    | impish          | source
 openssh | 1:8.4p1-6ubuntu2.1  | impish-updates  | source
 openssh | 1:8.8p1-1           | jammy           | source
 openssh | 1:8.9p1-3           | jammy-proposed  | source

リモートの情報を取得しに行くので回線がないと使えません.

$ https_proxy='dummy' rmadison openssh
curl: (5) Could not resolve proxy: dummy

こういった情報はこれまで https://packages.debian.org/ にアクセスして確認していたので便利になりました :)

$ w3m -dump https://packages.debian.org/openssh-server | grep ^Package\ openssh-server$ -A24
Package openssh-server

  • stretch (oldoldstable) (net): secure shell (SSH) server, for secure access
    from remote machines
    1:7.4p1-10+deb9u7: amd64 arm64 armel armhf i386 mips mips64el mipsel
    ppc64el s390x
  • buster (oldstable) (net): secure shell (SSH) server, for secure access from
    remote machines
    1:7.9p1-10+deb10u2: amd64 arm64 armel armhf i386 mips mips64el mipsel
    ppc64el s390x
  • buster-backports (net): secure shell (SSH) server, for secure access from
    remote machines
    1:8.4p1-2~bpo10+1: amd64 arm64 armel armhf i386 mips mips64el mipsel
    ppc64el s390x
  • bullseye (stable) (net): secure shell (SSH) server, for secure access from
    remote machines
    1:8.4p1-5: amd64 arm64 armel armhf i386 mips64el mipsel ppc64el s390x
  • bookworm (testing) (net): secure shell (SSH) server, for secure access from
    remote machines
    1:8.8p1-1: amd64 arm64 armel armhf i386 mips64el mipsel ppc64el s390x
  • sid (unstable) (net): secure shell (SSH) server, for secure access from
    remote machines
    1:8.9p1-3: alpha amd64 arm64 armel armhf hppa i386 ia64 m68k mips64el
    mipsel ppc64 ppc64el riscv64 s390x sh4 sparc64 x32
環境
dison --version
rmadison 0.4 (devscripts 2.22.1)
(C) 2006-2010 Christoph Berg <myon@debian.org>
(C) 2010 Uli Martens <uli@youam.net>
$ dpkg-query -W devscripts
devscripts      2.22.1
$ lsb_release -dr
Description:    Debian GNU/Linux bookworm/sid
Release:        unstable
$ arch
x86_64
]]>
https://matoken.org/blog/2022/03/03/check-the-package-version-with-rmadison/feed/ 0
Debian 10 Buster testing をリリース後に apt update するとエラーになる https://matoken.org/blog/2019/07/11/apt-update-after-releasing-debian-10-buster-testing-results-in-an-error/ https://matoken.org/blog/2019/07/11/apt-update-after-releasing-debian-10-buster-testing-results-in-an-error/#respond Wed, 10 Jul 2019 21:22:00 +0000 http://matoken.org/blog/?p=2420

2019-07-06 に Debian Buster 10 がリリースされました.

Debian 10 Buster testing 環境でリリース後に apt update をするとエラーになってしまいます.

$ sudo apt update
Get:1 http://security.debian.org/debian-security buster/updates InRelease [39.1 kB]
Get:2 http://deb.debian.org/debian buster InRelease [118 kB]
N: Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Version' value from '' to '10'
E: Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Suite' value from 'testing' to 'stable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
Do you want to accept these changes and continue updating from this repository? [y/N]
N: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Version' value from '' to '10.0'
E: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Suite' value from 'testing' to 'stable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
Do you want to accept these changes and continue updating from this repository? [y/N]
Reading package lists... Done
E: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease
E: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease
E: Some index files failed to download. They have been ignored, or old ones used instead.

--allow-releaseinfo-change を指定してAPT にリリースを情報を確認したことを教えます.

$ sudo apt --allow-releaseinfo-change update

次からはオプション無しで実行してもエラーが出なくなります.

$ sudo apt update
Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://security.debian.org/debian-security buster/updates InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.

ちなみに stable でなく testing 環境を使い続けたい場合は /etc/apt/sources.list を現在の Debian testing の bullseye に修正すればいいはず.

環境
$ dpkg-query -W apt
apt     1.8.2
$ hostnamectl | egrep 'Operating System|Architecture'
  Operating System: Debian GNU/Linux 10 (buster)
      Architecture: x86-64

]]>
https://matoken.org/blog/2019/07/11/apt-update-after-releasing-debian-10-buster-testing-results-in-an-error/feed/ 0
特定グループでのみ dmesg command を有効にする https://matoken.org/blog/2019/03/03/enable-dmesg-command-only-for-certain-groups/ https://matoken.org/blog/2019/03/03/enable-dmesg-command-only-for-certain-groups/#comments Sun, 03 Mar 2019 13:43:09 +0000 http://matoken.org/blog/?p=2304 Debian の linux 4.8.0 以降で一般ユーザによる dmesg が無効化されたので,kernelパラメータの kernel.dmesg_restrict を修正して dmesg command を一般ユーザでも実行できるようにしましたがこれだと全ユーザで実行できてしまいます.sudo を設定してログの読める adm ユーザだけが dmesg command を実行できるようにしてみました.

dmesgを実行したいユーザをadm group に登録する(loginし直して反映しておく)

$ sudo addgroup matoken adm
$ exit

visudo command で /etc/sudoers を編集して adm group は NOPASSWD で dmesg command を実行できるようにする(念の為編集前にもう1枚端末を開いて sudo -s しておいたり,at等で5分後に /etc/sudoers を巻き戻すようにしておくとミスっても安心)

$ sudo visudo
$ sudo git diff /etc/sudoers
diff --git a/sudoers b/sudoers
index d4cc632..ac3bd77 100644
--- a/sudoers
+++ b/sudoers
@@ -21,6 +21,7 @@ root  ALL=(ALL:ALL) ALL

 # Allow members of group sudo to execute any command
 %sudo  ALL=(ALL:ALL) ALL
+%adm   ALL=NOPASSWD: /usr/bin/dmesg

 # See sudoers(5) for more information on "#include" directives:

adm group のユーザでdmesg コマンドが追加されているのを確認

$ sudo -l | grep dmesg
    (root) NOPASSWD: /usr/bin/dmesg

adm group のユーザが認証無しで sudo dmesg が実行できるのを確認

$ id | grep -o adm
adm
$ sudo dmesg -H | tail -1
[  +0.015080] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1

このとき kernel.dmesg_restrict = 1 で sudo を通さないと dmesg は実行できない

$ cat /proc/sys/kernel/dmesg_restrict
1
$ dmesg 
dmesg: read kernel buffer failed: Operation not permitted
$ LC_MESSAGES=ja_JP.UTF-8 dmesg 
dmesg: read kernel buffer failed: 許可されていない操作です

~/.profile にalias を設定

$ echo 'alias dmesg="sudo dmesg"' | tee -a ~/.profile                                                                                                                                   
alias dmesg="sudo dmesg"
$ source ~/.profile
$ dmesg -H | tail -1
[  +0.015080] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1

環境

$ dpkg-query -W sudo util-linux linux-image-*
linux-image-4.19.0-2-arm64      4.19.16-1
linux-image-4.19.0-2-arm64-unsigned
linux-image-arm64       4.19+102
sudo    1.8.27-1
util-linux      2.33.1-0.1
$ lsb_release -dr
Description:    Debian GNU/Linux buster/sid
Release:        testing
$ uname -a
Linux rpi3 4.19.0-2-arm64 #1 SMP Debian 4.19.16-1 (2019-01-17) aarch64 GNU/Linux
$ cat /proc/device-tree/model ;echo
Raspberry Pi 3 Model B Rev 1.2

]]>
https://matoken.org/blog/2019/03/03/enable-dmesg-command-only-for-certain-groups/feed/ 1
Debian buster/sid でdmesgを一般ユーザで実行 https://matoken.org/blog/2019/03/03/run-dmesg-as-a-general-user-with-debian-buster-sid/ https://matoken.org/blog/2019/03/03/run-dmesg-as-a-general-user-with-debian-buster-sid/#comments Sun, 03 Mar 2019 13:07:56 +0000 http://matoken.org/blog/?p=2302 ※この方法だと全ユーザで dmesg が実行できてしまうので sudo を使ってグループを制限する次の方法のほうがいいかもしれない.


Debian buster arm64 環境を作りました( Raspberry Pi 3 Model B の USB起動で Debian buster arm64 を動かす – matoken’s meme )が,dmesg でエラーとなります.sudo dmesg は動く.

$ dmesg 
dmesg: read kernel buffer failed: Operation not permitted
$ LC_MESSAGES=ja_JP.UTF-8 dmesg 
dmesg: read kernel buffer failed: 許可されていない操作です

そういえば以前 Debian sid amd64 でも起こった現象です.
Debian では Linux 4.8.0 から仕様が変わってroot 以外ではdmesg が読めないようになっています.log file の読める adm group のユーザも駄目.
これは kernelパラメータの kernel.dmesg_restrict で設定されていて以下のようなコマンドで確認できます.

$ sudo sysctl -a|grep dmesg
kernel.dmesg_restrict = 1
$ cat /proc/sys/kernel/dmesg_restrict
1

これを 1 から 0 に変更することで以前と同じ動作となります.sysctl コマンドや,

$ sudo sysctl -w kernel.dmesg_restrict=0

/proc/sys/kernel/dmesg_restrict を直接書き換えることで一時的に変更できます.

echo 0 | sudo tee /proc/sys/kernel/dmesg_restrict

動きました.

$ id | grep -o adm
$ echo hello | sudo tee /dev/kmsg 
hello
[  562.152729] hello
$ dmesg -H | tail
[  +0.019933] brcmfmac mmc1:0001:1: firmware: failed to load brcm/brcmfmac43430-sdio.clm_blob (-2)
[  +0.020182] firmware_class: See https://wiki.debian.org/Firmware for information about missing firmware
[  +0.020886] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.clm_blob failed with error -2
[  +0.021916] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
[  +0.026818] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct 23 2017 03:55:53 version 7.45.98.38 (r674442 CY) FWID 01-e58d219f
[  +0.077925] systemd-udevd[376]: link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
[  +0.537137] EXT4-fs (sda2): re-mounted. Opts: (null)
[  +2.001639] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[  +1.563625] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
[Mar 2 05:58] hello

再起動すると元に戻ってしまうので,/etc/sysctl.d/local.conf などに設定を書いてくと次回起動時以降も反映されます.

$ sudo install -m 644 -o root -g root /dev/null /etc/sysctl.d/local.conf
$ echo 'kernel.dmesg_restrict = 0' | sudo tee -a /etc/sysctl.d/local.conf
kernel.dmesg_restrict = 0

試した環境

$ dmesg --version
dmesg from util-linux 2.33.1
$ dpkg-query -W util-linux linux-image-*
linux-image-4.19.0-2-arm64      4.19.16-1
linux-image-4.19.0-2-arm64-unsigned
linux-image-arm64       4.19+102
util-linux      2.33.1-0.1
$ lsb_release -dr
Description:    Debian GNU/Linux buster/sid
Release:        testing
$ uname -a
Linux rpi3 4.19.0-2-arm64 #1 SMP Debian 4.19.16-1 (2019-01-17) aarch64 GNU/Linux
$ cat /proc/device-tree/model ;echo
Raspberry Pi 3 Model B Rev 1.2

]]>
https://matoken.org/blog/2019/03/03/run-dmesg-as-a-general-user-with-debian-buster-sid/feed/ 1
Raspberry Pi 3 Model B の USB起動で Debian buster arm64 を動かす https://matoken.org/blog/2019/03/01/launch-debian-buster-arm-64-with-raspberry-pi-3-model-b-usb-boot/ https://matoken.org/blog/2019/03/01/launch-debian-buster-arm-64-with-raspberry-pi-3-model-b-usb-boot/#comments Thu, 28 Feb 2019 21:41:13 +0000 http://matoken.org/blog/?p=2295 最近入手した(遅) RaspberryPi 3 model B で USB メモリ起動の Debian buster aarch64 を設定してみたときのメモです.

ジモティー経由で Raspberry Pi 3 model B を入手しました.Raspberry Pi 3 model B + USB Wi-Fi + USB Bluetooth + ケースのセットが2,500円 + 送料手数料 500円と安いです.普通に新品で買うと 8,000円近くすると思います.今この記事を書いている時点で未だ在庫はあるようなので興味のある人は買うといいかもしれません.(6個同梱可能なのでそれだと1個あたりが少し安くなるので近所の友達と買うといいかも)

IMG-20190208-184136IMG-20190208-185154IMG-20190208-185222IMG-20190213-212056

64bitになった Raspberry Pi は欲しいと思っていたので安く手に入って助かりました :)
(後継の Raspberry Pi 3 Model B+/A+ や,SoCが 3B と同じで無線機能のない 2B v1.2 とかも欲しいですね.)

Raspberry Pi 3 model B は 32bitだけでなく64bit も利用できるハードウェアです.せっかくなので 64bitで動かしたいけど今の時点では Raspbian は 32bitのみです.そこで Debian の arm64 を試すことにしました.

Raspberry Pi 3 用 Debian buster arm64 イメージの入手とUSBメモリへの書き込み

イメージは岩松さんの東京エリアDebian勉強会の資料を真似して作ろうと思っていたのですが,

DebianWiki の RaspberryPi3 の項目を見たら非公式だけどイメージがあったので今回はそれを利用しました.現在 testing の Buster のイメージが入手できます.

ストレージは通常 microSD を利用しますが,手持ちがないのと Raspberry Pi 3 B はUSB起動が可能なはずなのでUSBメモリを利用することにしました.USB 2.0接続の容量2GBのものを用意しました.

このような感じでイメージを入手してハッシュのチェックをした後USBメモリへ書き込みました.ここでは Linuxのddコマンドで書き込んでいますが,Etcherなどを利用すると色々な環境でGUIでの書き込みが可能です.
※イメージは最新のものを利用するようにしましょう.

$ wget -c https://people.debian.org/~gwolf/raspberrypi3/20190206/20190206-raspberry-pi-3-buster-PREVIEW.img.xz https://people.debian.org/~gwolf/raspberrypi3/20190206/20190206-raspberry-pi-3-buster-PREVIEW.img.xz.sha256
$ sha256sum -c ./20190206-raspberry-pi-3-buster-PREVIEW.img.xz.sha256
20190206-raspberry-pi-3-buster-PREVIEW.img.xz: 完了
$ xzcat 20190206-raspberry-pi-3-buster-PREVIEW.img.xz | pv | sudo dd of=/dev/sdb bs=1M oflag=dsync

USBから起動できるようOTPを設定する

注意:OTPの設定は1度しか出来ないし,元に戻すことも出来ないと思われます.起動時間が長くなるなどデメリットもあるので気をつけて設定してください.

このUSBメモリを Raspberry Pi に接続して電源を入れてみましたが起動しません.恐らく OTP(One Time Programmable)メモリの設定が USB起動に対応していないので以下のページを参考に設定します.(Raspberry Pi 3+ シリーズは標準でUSB起動可能なのでこの設定は不要なはずです.)

先ず Raspbian 2017-04-10 以降のイメージを書き込んだ microSD を用意して起動します.
( uart経由で繋ぎたい場合起動前に /boot/config.txt に enable_uart=1 を書いておきます. $ echo enable_uart=1 | tee -a /media/matoken/boot/config.txt )

OTP を確認するとやはり有効になっていませんでした.

pi@raspberrypi:~$ vcgencmd otp_dump | grep ^17:
17:1020000a

以下のように /boot/config.txtprogram_usb_boot_mode=1 を追記して再起動すると反映されます.

$ echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
program_usb_boot_mode=1
pi@raspberrypi:~$ sudo reboot

17 が 3020000a に変わればOK

pi@raspberrypi:~$ vcgencmd otp_dump | grep ^17:
17:3020000a

詳細は以下を参照してください

17 – bootmode register

Bit 1: sets the oscillator frequency to 19.2MHz
Bit 3: enables pull ups on the SDIO pins
Bit 19: enables GPIO bootmode
Bit 20: sets the bank to check for GPIO bootmode
Bit 21: enables booting from SD card
Bit 22: sets the bank to boot from
Bit 28: enables USB device booting
Bit 29: enables USB host booting (ethernet and mass storage)

設定前が,1020000a -> 0b010000001000000000000000001010 で設定後が,0x3020000a -> 0b110000001000000000000000001010 てことで,Bit 29 が 0 から 1 になってネットワーク起動とUSB起動を試すようにります.この状態で microSD 起動を試すとこれも大丈夫でした.(優先度は microSD > USB,Networkは未確認)

USBメモリからの起動

この状態で shutdown し,microSD を取り出して Debian の導入した USB メモリを接続して起動で起動しました.(USB起動の場合なかなか起動が始まらず焦ったけど30秒ほど待つとUARTにログが出はじめる.HDMIの出力は未確認)

login は root:raspberry
ちゃんと 64bit です :)

root@rpi3:~# uname -a
Linux rpi3 4.19.0-2-arm64 #1 SMP Debian 4.19.16-1 (2019-01-17) aarch64 GNU/Linux

細々とした設定(ほぼ余録)

パッケージの更新

root@rpi3:~# apt update && apt upgrade

一般ユーザの追加

root@rpi3:~# useradd -m matoken
root@rpi3:~# passwd matoken
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@rpi3:~# chsh matoken -s /bin/bash

OpenSSH の設定変更

root@rpi3:~# diff -u /etc/ssh/sshd_config.old /etc/ssh/sshd_config
--- /etc/ssh/sshd_config.old    2019-02-06 15:15:46.940904823 +0000
+++ /etc/ssh/sshd_config        2019-02-16 13:17:17.076873278 +0000
@@ -29,7 +29,7 @@
 # Authentication:

 #LoginGraceTime 2m
-PermitRootLogin yes
+PermitRootLogin prohibit-password
 #StrictModes yes
 #MaxAuthTries 6
 #MaxSessions 10
@@ -53,7 +53,7 @@
 #IgnoreRhosts yes

 # To disable tunneled clear text passwords, change to no here!
-#PasswordAuthentication yes
+PasswordAuthentication no
 #PermitEmptyPasswords no

 # Change to yes to enable challenge-response passwords (beware issues with
@@ -119,3 +119,5 @@
 #      AllowTcpForwarding no
 #      PermitTTY no
 #      ForceCommand cvs server
+
+AllowGroups sshusers

sshusers グループを作成して ssh login 出来るユーザを登録

root@rpi3:~# sudo groupadd sshusers
root@rpi3:~# sudo usermod -a -G sshusers matoken

短いmodulus を削除する

root@rpi3:~# awk '$5>=3071' /etc/ssh/moduli | tee /etc/ssh/moduli.tmp
root@rpi3:~# wc -l /etc/ssh/moduli /etc/ssh/moduli.tmp
    427 /etc/ssh/moduli
    368 /etc/ssh/moduli.tmp
    795 total
root@rpi3:~# sudo mv /etc/ssh/moduli.tmp /etc/ssh/moduli

hostpcからssh公開鍵をcpしておく

$ ssh-copy-id -i ~/.ssh/id_ed25519_pi.pub matoken@rpi3

ssh鍵ペアを作っておく

root@rpi3:~# sudo -u matoken ssh-keygen -t ed25519

sshd の再起動

root@rpi3:~# systemctl restart ssh

ssh login時に通知を飛ばすようにしておく

root@rpi3:~# vi /etc/ssh/sshrc
root@rpi3:~# chmod +x /etc/ssh/sshrc
root@rpi3:~# cat /etc/ssh/sshrc
#!/bin/sh

/home/matoken/bin/telegram.sh sshrc:${USER}@`hostname`:${SSH_CONNECTION}
/home/matoken/bin/sms.sh sshrc:${USER}@`hostname`:${SSH_CONNECTION}

ssh でパスワードログインできず,鍵認証でログインが出来る&通知が飛ぶのを確認

root@rpi3:~# ssh root@localhost -o PasswordAuthentication=yes
root@rpi3:~# ssh matoken@localhost -o PasswordAuthentication=yes
root@rpi3:~# ssh matoken@localhost -i ~/.ssh/id_ed25519

自分のネットワークに合わせて /etc/iptables/rules.v4, /etc/iptables/rules.v6 を変更.

root@rpi3:~# grep -v ^# /etc/iptables/rules.v4
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -s 127.0.0.0/8 -m comment --comment "RFC3330 loopback" -j ACCEPT
-A INPUT -s 192.168.1.0/24 -m comment --comment "RFC1918 reserved" -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment SSH -j REJECT --reject-with icmp-port-unreachable
COMMIT
root@rpi3:~# grep -v ^# /etc/iptables/rules.v6
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -s ::1/128 -m comment --comment "RFC3513 loopback" -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m comment --comment SSH -j REJECT --reject-with icmp6-port-unreachable
COMMIT

sudo を導入して設定

root@rpi3:~# apt install sudo

sudo groupにユーザを登録

root@rpi3:~# usermod -a -G sudo matoken

sudo が利用できるのを確認

matoken@rpi3:~$ sudo grep ^root: /etc/shadow
sudo: unable to resolve host rpi3: Name or service not known
root:!..VyaTFxP8kT6:17933:0:99999:7:::

rootユーザをロック

$ sudo passwd -l root 
sudo: unable to resolve host rpi3: Name or service not known
passwd: password expiry information changed.
matoken@rpi3:~$ sudo passwd -S root
sudo: unable to resolve host rpi3: Name or service not known
root L 02/06/2019 0 99999 7 -1

sudo時などに「sudo: unable to resolve host rpi3: Name or service not known」と言われるので hosts の localhost に rpi3 を追加

matoken@rpi3:~$ sudo vi /etc/hosts
127.0.0.1 localhost rpi3

ここで再起動すると rootfs が見つからないと言われ起動しない.

(initramfs) Gave up waiting for root file system device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/mmcblk0p2 does not exist. Dropping to a shell!


BusyBox v1.27.2 (Debian 1:1.27.2-3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

cmdline では /dev/mmcblkp2 から起動しようとしているが, /dev/sda2 から起動したい

(initramfs) ls /dev
block tty12 tty47
bsg tty13 tty48
bus tty14 tty49
char tty15 tty5
console tty16 tty50
core tty17 tty51
cpu_dma_latency tty18 tty52
disk tty19 tty53
fb0 tty2 tty54
fd tty20 tty55
full tty21 tty56
gpiochip0 tty22 tty57
gpiochip1 tty23 tty58
input tty24 tty59
kmsg tty25 tty6
kvm tty26 tty60
mem tty27 tty61
memory_bandwidth tty28 tty62
network_latency tty29 tty63
network_throughput tty3 tty7
null tty30 tty8
port tty31 tty9
psaux tty32 ttyAMA0
ptmx tty33 ttyS0
pts tty34 ttyS1
random tty35 ttyS2
sda tty36 ttyS3
sda1 tty37 urandom
sda2 tty38 vcs
snapshot tty39 vcs1
stderr tty4 vcsa
stdin tty40 vcsa1
stdout tty41 vcsu
tty tty42 vcsu1
tty0 tty43 vga_arbiter
tty1 tty44 zero
tty10 tty45
tty11 tty46
(initramfs) cat /proc/cmdline
bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 dma.dmachans=0x7f35 bcm2709.boardrev=0xa02082 bcm2709.serial=0xfaf144 bcm2709.uart_clock=48000000 smsc95xx.macaddr=B8:27:EB:FA:F1:44 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=tty0 console=ttyS1,115200 root=/dev/mmcblk0p2 rw elevator=deadline fsck.repair=yes net.ifnames=0 cma=64M rootwait

/boot を mount して書き換えようと思ったけどうまく mount 出来ない?

(initramfs) mkdir /tmp/boot
(initramfs) mount /dev/sda1 /tmp/boot
mount: mounting /dev/sda1 on /tmp/boot failed: Invalid argument
(initramfs) ls -la /dev/sda1 /tmp/boot
brw-------    1 0        0           8,   1 Jan  1 00:00 /dev/sda1

/tmp/boot:
total 0
drwxr-xr-x    2 0        0                0 Jan  1 00:10 .
drwxr-xr-x    3 0        0                0 Jan  1 00:10 ..
(initramfs) mount -t vfat /dev/sda1 /tmp/boot
mount: mounting /dev/sda1 on /tmp/boot failed: No such device
(initramfs) mkdir /tmp/root
(initramfs) modprobe ext4
(initramfs) mount /dev/sda2 /tmp/root
[ 2144.515323] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)
(initramfs) find /tmp/root -name "vfat.ko"
/tmp/root/usr/lib/modules/4.19.0-2-arm64/kernel/fs/fat/vfat.ko
(initramfs) modprobe -v /tmp/root/usr/lib/modules/4.19.0-2-arm64/kernel/fs/fat/vfat.ko
(initramfs) lsmod|grep fat
(initramfs) mount -t vfat /dev/sda1 /tmp/boot
mount: mounting /dev/sda1 on /tmp/boot failed: No such device
(initramfs) lsmod|grep fat

一旦電源を切って /boot/cmdline.txt の root=/dev/mmcblk0p2 を root=/dev/sda2 に書き換えて起動するようになった.(LABEL指定に変えたほうがいいかな)

$ cat /boot/firmware/cmdline.txt 
console=tty0 console=ttyS1,115200 root=/dev/sda2 rw elevator=deadline fsck.repair=yes net.ifnames=0 cma=64M rootwait

raspi3-firmware あたりのアップデートが掛かると上書きされるよう.

systemd から sysvinit に変更(RAMが開くかと思ったけど数MB程度だった)

$ sudo apt install sysvinit-core sysvinit-utils

LANGを設定
en_US.UTF-8 UTF-8, ja_JP.UTF-8 UTF-8 を有効にして,デフォルトロケールを ja_JP.UTF-8 にしたりした.

$ sudo dpkg-reconfigure locales
$ echo 'export LANG="ja_JP.UTF-8"
export LC_TIME="en_US.UTF-8"' | tee -a ~/.profile
$ source ~/.profile
$ locale
LANG=ja_JP.UTF-8
LANGUAGE=
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME=en_US.UTF-8
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=

Raspberry Pi には rtc がなくて再起動などで時計が初期化されてしまうので fake-hwclock を導入(電源断時などの時間はカウントされないので時間がずれるが時計が巻き戻らない)

$ sudo apt install fake-hwclock

ntpdate を導入して起動時の時計合わせをするようにする(systemdのままだとntpの面倒を見てくれるので必要ない)

$ sudo apt install ntpdate
$ sudo vi /etc/boot.d/ntpdate
$ cat /etc/boot.d/ntpdate
#!/bin/sh

ntpdate 1.jp.pool.ntp.org
$ sudo chmod +x /etc/boot.d/ntpdate

ntpdate iptables に合わせてこっちのほうがいいかも?(有線接続後に時計合わせする)

$ cat /etc/network/interfaces.d/eth0 
auto eth0

# TODO: switch back to iptables-persistent once it re-enters testing
iface eth0 inet dhcp
        pre-up iptables-restore < /etc/iptables/rules.v4
        pre-up ip6tables-restore < /etc/iptables/rules.v6
        up ntpdate 1.jp.pool.ntp.org

uartでsetial接続するために /etc/inittab に以下を設定(systemdだと設定済みなので不要)

T1:23:respawn:/sbin/getty -L ttyS1 115200 vt100

msmtpを導入してメールを飛ばせるように

$ sudo apt install msmtp
$ sudo vi /etc/msmtprc
$ grep -v ^# /etc/msmtprc|uniq
defaults
syslog on
aliases /etc/aliases

tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
auth on
syslog LOG_MAIL

account gmail
host smtp.gmail.com
port 587
from matohara@gmail.com
user matohara
password throjfeekdewxeib

account default : gmail
$ sudo vi /etc/aliases
$ grep -v ^# /etc/aliases
mailer-daemon:hoge@example.com
postmaster:hoge@example.com
nobody:hoge@example.com
hostmaster:hoge@example.com
usenet:hoge@example.com
news:hoge@example.com
webmaster:hoge@example.com
www:hoge@example.com
ftp:hoge@example.com
abuse:hoge@example.com
noc:hoge@example.com
security:hoge@example.com
root: hoge@example.com
default: hoge@example.com
$ echo 'hello' | msmtp matoken@ya.ru
$ sudo apt install msmtp-mta
$ echo 'hello' | /usr/sbin/sendmail matoken@ya.ru

無線を無効にするために /boot/firmware/config.txt に以下を追記……再起動しても反映されない?要確認

dtoverlay=pi3-disable-wifi
dtoverlay=pi3-disable-bt

apticron を導入して更新をメールで通知する

$ sudo apt install apticron
$ sudo cp -p /usr/lib/apticron/apticron.conf /etc/apticron/
$ grep ^EMAIL= /etc/apticron/apticron.conf #必要なら宛先を書き換えたり
EMAIL="root"

deborphan でみなしごパッケージを通知するようにする

$ sudo apt install deborphan
$ sudo crontab -e
$ sudo crontab -l | grep deborphan | grep -v ^#
7 4 * * *       deborphan && printf "\nsudo apt --autoremove purge \$( deborpha)'

てことでとりあえず動くようになったけど昔もらったノベルティのUSBメモリなのでこのまま運用すると多分すぐ壊れてしまうと思います.
最近秋葉原でセールになっている様な安い SSD とか欲しいですね.

こちらは起動終了のUARTのメッセージ

asciicast

]]>
https://matoken.org/blog/2019/03/01/launch-debian-buster-arm-64-with-raspberry-pi-3-model-b-usb-boot/feed/ 1
Debian, Ubuntu で 上流のパッケージを借りてくる https://matoken.org/blog/2018/10/23/debian-ubuntu-borrows-the-upstream-package/ https://matoken.org/blog/2018/10/23/debian-ubuntu-borrows-the-upstream-package/#comments Tue, 23 Oct 2018 14:10:12 +0000 http://matoken.org/blog/?p=2190

以前以下のような記事を書きました.

今でもこのblogの中ではアクセスが多く,最近もトラックバックをもらいました.

この当時は arm64 の mozcパッケージがなくて自分でbuild したという話なのですが,現在はDebian では buster(testing), Ubuntu ではartful(17.10) 以降でパッケージが存在します.
なのでこの野良パッケージを使うよりも公式の上流パッケージを借りるほうが大抵の場合いいと思います.
ということで手順を書いておきます.

パッケージファイルだけが必要な場合はパッケージのページからダウンロード可能です.

野良パッケージは近日中に削除します.

Debian stretch arm64 に Debian buster arm64 の mozc を借りてくる

Debian stretch arm64 では mozc-data しかない
$ apt-cache search mozc
mozc-data - Mozc input method - data files

buster(testing) のmozc を借りてくることにする.

/etc/apt/preferences で buster の優先度を下げる

/etc/apt/preferences
Package: *
Pin: release n=buster
Pin-Priority: 100
/etc/apt/sources.list に buster(testing)追加 設定
deb http://deb.debian.org/debian buster main

sources.list の編集には apt edit-sources を使うと文法チェックをしてくれるのでおすすめ

パッケージ情報の更新
$ sudo apt update
mozcパッケージの確認
$ apt-cache search mozc
mozc-data - Mozc input method - data files
fcitx-dbus-status - Addon for Fcitx to set/get/monitor IM statuses via D-Bus
emacs-mozc - Mozc for Emacs
emacs-mozc-bin - Helper module for emacs-mozc
fcitx-mozc - Mozc engine for fcitx - Client of the Mozc input method
ibus-mozc - Mozc engine for IBus - Client of the Mozc input method
mozc-server - Server of the Mozc input method
mozc-utils-gui - GUI utilities of the Mozc input method
uim-mozc - Mozc engine for uim - Client of the Mozc input method
パッケージの導入
$ apt install fcitx-mozc -t buster

後は通常の apt update && apt upgrade で stretch で導入したパッケージは stretch で,buster で導入したパッケージはbuster で更新されるはず.

Ubuntu 16.04 LTS xenial arm64 に Ubuntu 18.04 LTS bionic arm64 の mozc を借りてくる

Debianの手順と同じでもokだと思うけど念の為以下の手順を真似してみる.

mozc は Ubuntu 17.10 artful から対応しているが,もうサポートされないのでUbuntu 18.04 bionic を使う.

標準のリリースを xenial に設定

/etc/apt/apt.conf.d/01ubuntu
APT::Default-Release "xenial";

mozc をpinningする

/etc/apt/preferences
Package: *mozc*
Pin: release n=xenial
Pin-Priority: -10

Package: *mozc*
Pin: release n=bionic
Pin-Priority: 900

/etc/apt/sources.list に buster(testing) を 追加 設定

/etc/apt/sources.list
deb http://ports.ubuntu.com/ bionic main universe

※sources.list の編集には apt edit-sources を使うと文法チェックをしてくれるのでおすすめ
※mirrorにより arm64 が置かれていないので注意

パッケージ情報の更新
$ sudo apt update
検索結果にmozcが出てくる
$ apt-cache search mozc
mozc-data - Mozc input method - data files
ibus-mozc - Mozc engine for IBus - Client of the Mozc input method
mozc-server - Server of the Mozc input method
mozc-utils-gui - GUI utilities of the Mozc input method
emacs-mozc - Mozc for Emacs
emacs-mozc-bin - Helper module for emacs-mozc
fcitx-mozc - Mozc engine for fcitx - Client of the Mozc input method
uim-mozc - Mozc engine for uim - Client of the Mozc input method
パッケージの導入
$ sudo apt install fcitx-mozc -t bionic
]]>
https://matoken.org/blog/2018/10/23/debian-ubuntu-borrows-the-upstream-package/feed/ 2
Debianでもarm64でmozc build https://matoken.org/blog/2017/06/05/on-debian-mozc-build-with-arm64/ https://matoken.org/blog/2017/06/05/on-debian-mozc-build-with-arm64/#comments Sun, 04 Jun 2017 23:40:41 +0000 http://matoken.org/blog/?p=1618 EDIT: 現在は次の記事の手順のほうが良いと思います -> Debian, Ubuntu で 上流のパッケージを借りてくる – matoken’s meme


20170605_00:06:13-17276

先日Ubuntu 16.04 arm64環境でmozc pkgを作りました.

今回はDebian stretch arm64でも作ってみました.

環境はQualcomの96BoardのDragonBoard 410cにDebian stretch aarch64のイメージ(dragonboard410c_sdcard_install_debian-233.zip)を使いました.

OSイメージの入手や導入方法などは以下のあたりにあります.

手元では以下のような感じでsd cardに書き込んだ後dipスイッチでsd起動にして起動してeMMCに導入しました.

$ md5sum dragonboard410c_sdcard_install_debian-233.zip
ef17a1602cf0ef300e123a3224e0699d  dragonboard410c_sdcard_install_debian-233.zip
$ unzip -l dragonboard410c_sdcard_install_debian-233.zip
Archive:  dragonboard410c_sdcard_install_debian-233.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
4055891968  2017-05-11 05:25   db410c_sd_install_debian.img
    13953  2017-05-04 21:45   LICENSE
---------                     -------
4055905921                     2 files
$ unzip -p dragonboard410c_sdcard_install_debian-233.zip LICENSE | lv
$ unzip -p dragonboard410c_sdcard_install_debian-233.zip db410c_sd_install_debian.img | pv | sudo dd of=/dev/mmcblk0 bs=4M
$ sync
$ sync
$ sync

後の手順はほぼ前回のUbuntuと同じですが,

dpkg-buildpackage: error: fakeroot not found, either install the fakeroot
package, specify a command with the -r option, or run this as root  

とfakerootが無いと起こられたので導入パッケージにfakerootを追加したのと,

virtual memory exhausted: Cannot allocate memory

という感じでコケたので以下のような感じでスワップファイルを追加して回避しました.前回のUbuntuを入れてる方の機械はRAM2GBなのでRAM1GB+SWAP1GBでも行けると思いますが念の為2GB追加しました.

$ dd if=/dev/zero of=/var/tmp/swap bs=1M count=2048
$ sudo chmod 600 /var/tmp/swap
$ sudo chown 0.0 /var/tmp/swap
$ sudo mkswap /var/tmp/swap
$ sudo swapon /var/tmp/swap
$ free
              total        used        free      shared  buff/cache   available
Mem:         945868      225736      444948       40784      275184      608980
Swap:       2097148           0     2097148

で,パッケージングと導入の手順はこんな感じでした.

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install build-essential devscripts fakeroot
$ sudo apt build-dep mozc
$ apt source mozc
$ wget https://gist.githubusercontent.com/matoken/afce66ce67392c11d3ed20d7bbab5833/raw/2bb0163f30291caa6ba7b41b3d4352c7e6c0b6a7/patch
$ patch -p0 < patch
$ cd mozc-2.19.2623.102+dfsg
$ time dpkg-buildpackage -us -uc -j4
   :
real    111m31.882s
user    88m2.352s
sys     10m59.828s
$ dch -i
$ head debian/changelog 
mozc (2.19.2623.102+dfsg-1.1) unstable; urgency=medium

  * Non-maintainer upload.
  * Update debian/control.
    - Add arm64 to Architecture list.

 -- K.I.Matohara <matoken@gmail.com>  Sat, 03 Jun 2017 22:15:19 +0000

mozc (2.19.2623.102+dfsg-1) unstable; urgency=medium

$ dpkg-buildpackage -j4
$ ls -la ../*dfsg-1.1_*
-rw-r--r-- 1 linaro linaro  2130510 Jun  4 01:10 ../emacs-mozc-bin-dbgsym_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro   157710 Jun  4 01:10 ../emacs-mozc-bin_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro    28118 Jun  4 01:10 ../emacs-mozc_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro  2765446 Jun  4 01:10 ../fcitx-mozc-dbgsym_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro   224574 Jun  4 01:10 ../fcitx-mozc_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro  3088148 Jun  4 01:10 ../ibus-mozc-dbgsym_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro   189886 Jun  4 01:10 ../ibus-mozc_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro    14134 Jun  4 01:10 ../mozc-data_2.19.2623.102+dfsg-1.1_all.deb
-rw-r--r-- 1 linaro linaro 24825020 Jun  4 01:11 ../mozc-server-dbgsym_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro 12310852 Jun  4 01:11 ../mozc-server_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro  9823936 Jun  4 01:11 ../mozc-utils-gui-dbgsym_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro   755758 Jun  4 01:11 ../mozc-utils-gui_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro    18228 Jun  4 04:00 ../mozc_2.19.2623.102+dfsg-1.1_arm64.buildinfo
-rw-r--r-- 1 linaro linaro     6898 Jun  4 04:00 ../mozc_2.19.2623.102+dfsg-1.1_arm64.changes
-rw-r--r-- 1 linaro linaro  1921396 Jun  4 01:10 ../uim-mozc-dbgsym_2.19.2623.102+dfsg-1.1_arm64.deb
-rw-r--r-- 1 linaro linaro   192712 Jun  4 01:10 ../uim-mozc_2.19.2623.102+dfsg-1.1_arm64.deb
$ sudo apt install ../mozc-server_2.19.2623.102+dfsg-1.1_arm64.deb ../fcitx-mozc_2.19.2623.102+dfsg-1.1_arm64.deb ../mozc-data_2.19.2623.102+dfsg-1.1_all.deb ../mozc-utils-gui_2.19.2623.102+dfsg-1.1_arm64.deb 
$ sudo apt install fcitx-ui-classic

これも一応この辺に置いておきました.多分そのうち消します.(Versionが上がった頃?)

これでとりあえず手元のUbuntu/Debianで利用できるようになりましたが,mozcのバージョンアップ毎にbuildが必要です.なのでBTS予定.あとクロスで試すのとMultiarchも試してみたいです.

参考URL

]]>
https://matoken.org/blog/2017/06/05/on-debian-mozc-build-with-arm64/feed/ 1
Raspberry PiのFreedomBoxで/var/lib/dpkg/statusが壊れたのを復旧 https://matoken.org/blog/2017/04/19/restore-broken-var-lib-dpkg-status-in-freedombox-of-raspberry-pi/ https://matoken.org/blog/2017/04/19/restore-broken-var-lib-dpkg-status-in-freedombox-of-raspberry-pi/#respond Tue, 18 Apr 2017 15:49:36 +0000 http://matoken.org/blog/?p=1601 Raspberry PiでFreedomBoxを試しているのですが,ストレージがmicroSDのせいか修正していたパッケージの依存関係か何かがおかしくなったせいか/var/lib/dpkg/statusが壊れてしまいました.

$ sudo apt update
Hit:1 http://cdn-fastly.deb.debian.org/debian testing InRelease
Reading package lists... Error!
E: Unable to parse package file /var/lib/dpkg/status (1)
W: You may want to run apt-get update to correct these problems
E: The package cache file is corrupted
E: パッケージファイル /var/lib/dpkg/status を解釈することができません (1)
W: これらの問題を解決するためには apt-get update を実行する必要があるかもしれません
E: パッケージキャッシュファイルが壊れています

apt-get updateで治るのかなと思って叩いてみましたが駄目でした.

Debian リファレンス第2章 Debian パッケージ管理によると,

2.6.5. パッケージセレクションの復元

もし何らかの理由で “/var/lib/dpkg/status” の内容が腐った場合には、Debian システムはパッケージ選択データーが失われ大きな打撃を被ります。古い “/var/lib/dpkg/status” ファイルは、”/var/lib/dpkg/status-old” や “/var/backups/dpkg.status.*” としてあるので探します。

“/var/backups/” は多くの重要な情報を保持しているので、これを別のパーティション上に置くのも良い考えです。

とのことなので,/var/lib/dpkg/status-oldから復旧をと思いましたがこれも既に壊れているバージョン./var/backups/dpkg.status.0はまだ壊れていなかったのでこれで上書きして復旧したようです.

$ sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status
]]>
https://matoken.org/blog/2017/04/19/restore-broken-var-lib-dpkg-status-in-freedombox-of-raspberry-pi/feed/ 0
ディスクイメージのデバイスマップが簡単に作れるkpartxを試す https://matoken.org/blog/2017/04/12/try-kpartx-which-makes-it-easy-to-create-device-map-of-disk-image/ https://matoken.org/blog/2017/04/12/try-kpartx-which-makes-it-easy-to-create-device-map-of-disk-image/#comments Tue, 11 Apr 2017 21:46:23 +0000 http://matoken.org/blog/?p=1599 以下のページでkpartxというディスクのデバイスマップを作るコマンドがあるのを知りました

そこでまず、kpartxを使って各パーティションのデバイスマップを作ります。
$ sudo /sbin/kpartx -av /opt/atde3-20100309.img
add map loop2p1 : 0 497952 linear /dev/loop2 63
add map loop2p2 : 0 33045705 linear /dev/loop2 498015
$ ls /dev/mapper/
control loop2p1 loop2p2
これでディスクイメージの各物理パーティションに対応したデバイスマップができました。fdiskで見えていたパーティションはそれぞれ、/dev/mapper/loop2p1 /dev/mapper/loop2p2 として参照できるようになっています。

これまでは以下のページのようにfdiskコマンドでパーティション情報を確認してmount時にoffsetを指定していました.

kpartxを使うとこの作業が簡単になりそうなので試してみました.

Debian sid amd64ではそのままkpartxパッケージだったのでこれを導入します.(Ubuntu 17.04 amd64でも同様でした.)

$ sudo apt install kpartx

丁度Raspbian jessie 2017-04-10が出たのでこれで試してみます.

$ unzip -l 2017-04-10-raspbian-jessie-lite.zip 
Archive:  2017-04-10-raspbian-jessie-lite.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
1297862656  2017-04-10 18:58   2017-04-10-raspbian-jessie-lite.img
---------                     -------
1297862656                     1 file
$ time unzip 2017-04-10-raspbian-jessie-lite.zip
Archive:  2017-04-10-raspbian-jessie-lite.zip
  inflating: 2017-04-10-raspbian-jessie-lite.img  

real    2m58.438s
user    0m27.512s
sys     0m2.132s
 sudo /sbin/kpartx -av 2017-04-10-raspbian-jessie-lite.img
add map loop0p1 (254:3): 0 83968 linear 7:0 8192
add map loop0p2 (254:4): 0 2442728 linear 7:0 92160
$ ls -lA /dev/mapper/
合計 0
crw------- 1 root root 10, 236  4月 11 23:37 control
lrwxrwxrwx 1 root root       7  4月 12 06:07 loop0p1 -> ../dm-3
lrwxrwxrwx 1 root root       7  4月 12 06:07 loop0p2 -> ../dm-4
lrwxrwxrwx 1 root root       7  4月 11 23:37 sda3_crypt -> ../dm-0
lrwxrwxrwx 1 root root       7  4月 11 23:37 x220--vg-root -> ../dm-1
lrwxrwxrwx 1 root root       7  4月 11 23:37 x220--vg-swap_1 -> ../dm-2

デバイスマッピングされています.これで簡単にmount出来ました.

$ sudo mount -o ro /dev/mapper/loop0p1 /media/mk/pi-boot
$ sudo mount -o ro /dev/mapper/loop0p2 /media/mk/pi-root/
$ mount | grep /dev/mapper/loop0p
/dev/mapper/loop0p1 on /media/mk/pi-boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/mapper/loop0p2 on /media/mk/pi-root type ext4 (ro,relatime,data=ordered)
$ ls /media/mk/pi-boot
COPYING.linux     bcm2708-rpi-0-w.dtb     bcm2708-rpi-cm.dtb   bcm2710-rpi-cm3.dtb  config.txt    fixup_db.dat  kernel.img   start.elf     start_x.elf
LICENCE.broadcom  bcm2708-rpi-b-plus.dtb  bcm2709-rpi-2-b.dtb  bootcode.bin         fixup.dat     fixup_x.dat   kernel7.img  start_cd.elf
LICENSE.oracle    bcm2708-rpi-b.dtb       bcm2710-rpi-3-b.dtb  cmdline.txt          fixup_cd.dat  issue.txt     overlays     start_db.elf
$ ls /media/mk/pi-root
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

そしてchrootしてみたり

$ sudo mount -o remount,rw /media/mk/pi-root
$ sudo cp -p /usr/bin/qemu-arm-static /media/mk/pi-root/usr/bin
$ sudo chroot /media/mk/pi-root/ /bin/bash
# dpkg --get-selections "*" | wc -l
427

アンマウントして元に戻します.

# exit
$ sudo umount /media/mk/pi-*
$ sudo kpartx -d /dev/mapper/loop0p1
$ sudo kpartx -d /dev/mapper/loop0p2
$ rm ./2017-04-10-raspbian-jessie-lite.img

便利ですね :)
後は圧縮ファイルをそのまま使えると便利なんですがムリカナ?

]]>
https://matoken.org/blog/2017/04/12/try-kpartx-which-makes-it-easy-to-create-device-map-of-disk-image/feed/ 2
etckeeperのmanに載っているREADMEを読もうと思ったら無い https://matoken.org/blog/2017/04/05/no-serch-file-readme-of-etckeeper-man/ https://matoken.org/blog/2017/04/05/no-serch-file-readme-of-etckeeper-man/#respond Wed, 05 Apr 2017 00:08:46 +0000 http://matoken.org/blog/?p=1588 Debian sid amd64のetckeeperのmanに載っているREADMEを読もうと思ったらそんなファイルは無い.

$ man etckeeper | grep -B1 README
SEE ALSO
       /usr/share/doc/etckeeper/README.md.gz
$ lv /usr/share/doc/etckeeper/README.md.gz
/usr/share/doc/etckeeper/README.md.gz: No such file or directory
$ ls -lA /usr/share/doc/etckeeper/
合計 40
-rw-r--r-- 1 root root  4679  7月 18  2016 README.mdwn.gz
-rw-r--r-- 1 root root 11645  8月  2  2016 changelog.Debian.gz
-rw-r--r-- 1 root root  1785  7月 18  2016 copyright
-rw-r--r-- 1 root root   948  7月 18  2016 index.mdwn
-rw-r--r-- 1 root root   483  7月 18  2016 install.mdwn
-rw-r--r-- 1 root root    55  7月 18  2016 news.mdwn
-rw-r--r-- 1 root root   309  7月 18  2016 todo.mdwn
$ dpkg -L etckeeper | grep README
/etc/etckeeper/commit.d/README
/etc/etckeeper/init.d/README
/etc/etckeeper/post-install.d/README
/etc/etckeeper/pre-commit.d/README
/etc/etckeeper/pre-install.d/README
/etc/etckeeper/unclean.d/README
/etc/etckeeper/uninit.d/README
/etc/etckeeper/update-ignore.d/README
/usr/share/doc/etckeeper/README.mdwn.gz
$ dpkg-query -W etckeeper
etckeeper       1.18.5-1

/usr/share/doc/etckeeper/README.mdwn.gzが内容からしてそれぽい.
バグぽいので報告しようかと思って既存のバグを眺めると既に報告されて上流で修正済みのようでした.

]]>
https://matoken.org/blog/2017/04/05/no-serch-file-readme-of-etckeeper-man/feed/ 0
バックライト制御コマンドのybacklight https://matoken.org/blog/2017/04/05/backlight-controle-command-ybacklight/ https://matoken.org/blog/2017/04/05/backlight-controle-command-ybacklight/#comments Tue, 04 Apr 2017 23:33:17 +0000 http://matoken.org/blog/?p=1586 awesome wmでバックライトの制御にxbacklightコマンドを使っていたのですが,手元のDebian sid amd64環境ではNo outputs have backlight propertyというエラーで現在利用できなくなっています.

$ xbacklight -get
No outputs have backlight property
$ xbacklight = 100
No outputs have backlight property
$ xbacklight + 10
No outputs have backlight property
$ xbacklight - 10
No outputs have backlight property

workaroundとしてこんな感じで手で叩いていてちょっとあれです.持ち出さないPCなのであまり操作しないのでどうにかなってるけど不便です.

$ sudo sh -c "echo 1000 > /sys/class/backlight/intel_backlight/brightness"

しかし,gdm3のログイン画面ではFn+Home/Fm+Endでバックライトの変更が出来ることに気づきました.
なんか進展あったのかな?とバグレポを眺めているとそれらしいものは見つからないけれど,

ybacklightというものが紹介されているのに気づきました.

利用方法はxbacklightと同じです.

$ ybacklight -h
Usage: /home/mk/bin/ybacklight [options]
  Options:
  -d <driver> or -driver <driver>: Use driver <driver> (NB: -display is
                                   also supported for compatibility)
  -help: Print this help
  -set <percentage> or = <percentage>: Set backlight to <percentage>
  -inc <percentage> or + <percentage>: Increase backlight by <percentage>
  -dec <percentage> or - <percentage>: Decrease backlight by <percentage>
  -get: Get backlight percentage
  -time <ignored> or -steps <ignored>: Unsupported, ignored
  -v: Verbose output

読むのはいけますが,変更は出来ません.

$ ybacklight -get
30
$ ybacklight +10
Permissions conflict.  Can't write to: ( /sys/class/backlight/intel_backlight/brightness )

/sys/class/backlight/intel_backlight/brightnessに書き込み権をつけると行けます.

$ ls -l /sys/class/backlight/intel_backlight/brightness
-rw-r--r-- 1 root root 4096  4月  5 06:48 /sys/class/backlight/intel_backlight/brightness
$ sudo chmod o+w /sys/class/backlight/intel_backlight/brightness
$ ls -l /sys/class/backlight/intel_backlight/brightness
-rw-r--rw- 1 root root 4096  4月  5 06:48 /sys/class/backlight/intel_backlight/brightness
$ ybacklight +10
40
$ ybacklight -10
30

ちょっと微妙.

]]>
https://matoken.org/blog/2017/04/05/backlight-controle-command-ybacklight/feed/ 2
gdm3でユーザーリストの非表示が無効になっていたのを調べる https://matoken.org/blog/2017/04/05/check-that-hidden-user-list-was-disabled-on-gdm3/ https://matoken.org/blog/2017/04/05/check-that-hidden-user-list-was-disabled-on-gdm3/#respond Tue, 04 Apr 2017 22:53:11 +0000 http://matoken.org/blog/?p=1584 Debian sid amd64のgdm3の画面でユーザーリストを表示しないようにしていたのですが,表示されるようになっていました.

これまでは,
/etc/gdm3/greeter.dconfファイルの以下の設定を有効にしていました.

disable-user-list=true

$ apt-get changelog gdm3( /usr/share/doc/gdm3/changelog.Debian.gz)を見るとこんな記述が,

  * greeter.dconf-defaults: this is a new file to remove the old 
    greeter.gsettings
  * Convert greeter.gsettings to greeter.dconf-defaults at postinst time 
    and use ucf to update the file.
  * Make a direct symlink to the new greeter.dconf-defaults file in the 
    dconf defaults directory.

gdm3 (3.12.1-1)からgreeter.dconf-defaultsに変わったようです.

$ ls /etc/gdm3/
Init  PostLogin  PostSession  PreSession  Xsession  daemon.conf  daemon.conf.dpkg-dist  greeter.dconf  greeter.dconf-defaults  greeter.dconf-defaults.ucf-old

内容はほとんど同じなようです.

$ diff  /etc/gdm3/greeter.dconf /etc/gdm3/greeter.dconf-defaults
26,27d25
< #logo='/usr/share/icons/gnome/48x48/places/debian-swirl.png'
< #fallback-logo='/usr/share/icons/gnome/48x48/places/debian-swirl.png'
31d28
< 
33c30
< disable-user-list=true
---
> # disable-user-list=true
37,38c34,35
< #banner-message-enable=true
< #banner-message-text='Welcome!!!!!!!!!!!!!!!!!!!!!!'
---
> # banner-message-enable=true
> # banner-message-text='Welcome'

ということで/etc/gdm3/greeter.dconf-defaultsdisable-user-list=trueを有効にしたらOKでした.

diff --git a/gdm3/greeter.dconf-defaults b/gdm3/greeter.dconf-defaults
index c5b0786..b0ee10c 100644
--- a/gdm3/greeter.dconf-defaults
+++ b/gdm3/greeter.dconf-defaults
@@ -27,7 +27,7 @@ logo='/usr/share/icons/hicolor/48x48/emblems/emblem-debian-white.png'
 fallback-logo='/usr/share/icons/hicolor/48x48/emblems/emblem-debian-white.png'

 # - Disable user list
-# disable-user-list=true
+disable-user-list=true
 # - Disable restart buttons
 # disable-restart-buttons=true
 # - Show a login welcome message

#ちなみにこのとき$ sudo service gdm3 restartとしたらなんかおかしくなってしまいました…….OSごと再起動したら治りました.

次から気づきやすいように

$ sudo dpkg-reconfigure apt-listchanges

で「APTで表示すべき変更内容の種類を選択してください。」を「両方 – ニュースと changelog の両方」にしておきました.testing/unstable辺りはちゃんと読まないとですね…….

※apt-listchangesが入っていない場合は$ sudo apt install apt-listchanges

]]>
https://matoken.org/blog/2017/04/05/check-that-hidden-user-list-was-disabled-on-gdm3/feed/ 0
ext4の暗号化fsを試してみる https://matoken.org/blog/2017/04/02/try-ext4-encryption-file-system/ https://matoken.org/blog/2017/04/02/try-ext4-encryption-file-system/#respond Sat, 01 Apr 2017 23:20:44 +0000 http://matoken.org/blog/?p=1579 Linux 4.1でext4の暗号化ファイルシステムが取り込まれているのに気づいたので少し試してみました.
cCryptFSやEncFSなどと同じようにファイル単位での暗号化です.前もって暗号化フラグを設定してあれば一般ユーザが勝手に暗号領域を作ることも可能でした.eCryptFSやEncFSのような使い方も可能そうです.恐らく速度はこちらのほうが速いでしょう(未確認).ただ,パスフレーズがわかってしまうと別のユーザからもマウント可能だしパーミッションがあれば読み書きも出来るので通常のファイルシステムと同様パーミッションの設定は必須ですね.
パーティション内全てを暗号化することは出来ないようなのでLUKS(dm-crypt)とは単純に空きかえることはできなさそうです.

そんなこんなでもともとAndroid向けということもあってPC/Serverではあまり使いみちが思いつかない感じです.(何かいい使い方ありそうだけど…….)

必要条件確認

  • Linux 4.1以上
$ uname -r
4.9.0-2-amd64
  • CONFIG_EXT4_ENCRYPTIONが有効
$ grep CONFIG_EXT4_ENCRYPTION /boot/config-`uname -r`
CONFIG_EXT4_ENCRYPTION=y
  • e2fsprogs 1.43以上
$ dpkg-query -W e2fsprogs
e2fsprogs       1.43.4-2
  • ブロックサイズが4k
$ sudo dumpe2fs /dev/loop0 | grep -i 'block size'
dumpe2fs 1.43.4 (31-Jan-2017)
Block size:               4096

必要なパッケージの導入

$ sudo apt install e2fsprogs keyutils util-linux coreutils mount

ファイルシステムの用意

今回は既存のファイルシステム内にディスクイメージを作成してそれを利用

  • 1GBのディスクイメージの作成
$ dd if=/dev/zero of=ext4-crypt.img seek=1073741824 bs=1 count=1
1+0 レコード入力
1+0 レコード出力
1 byte copied, 0.000118528 s, 8.4 kB/s
  • パーティションの作成
    primaryを1つ作成
$ /sbin/fdisk ext4-crypt.img

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xa25a3988.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-2097151, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151): 

Created a new partition 1 of type 'Linux' and of size 1023 MiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.
  • ext4でフォーマット
$ /sbin/mkfs.ext4 ./ext4-crypt.img 
mke2fs 1.43.4 (31-Jan-2017)
Found a dos partition table in ./ext4-crypt.img
Proceed anyway? (y,N) y
Discarding device blocks: done                            
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: dc44fd43-7d7a-4dfc-87f1-dc52410e2dd1
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
  • マウント
$ sudo mount -o loop ./ext4-crypt.img /mnt
$ grep /mnt /etc/mtab 
/dev/loop0 /mnt ext4 rw,relatime,data=ordered 0 0
  • オーナー,グループの変更
$ sudo chown `id -u`.`id -g` /mnt
$ ls -la /mnt
合計 36
drwxr-xr-x 3 mk   mk    4096  4月  2 04:58 .
drwxr-xr-x 1 root root   248  3月 28 02:19 ..
drwx------ 2 root root 16384  4月  2 04:58 lost+found

ext4暗号化ファイルシステムの利用

  • ext4の暗号化フラグを設定
$ sudo tune2fs -O encrypt /dev/loop0
$ sudo dumpe2fs /dev/loop0 | grep -io encrypt
dumpe2fs 1.43.4 (31-Jan-2017)
encrypt
  • 鍵の生成とキーリングへの追加
$ /usr/sbin/e4crypt add_key
Enter passphrase (echo disabled): 
Added key with descriptor [07a3ce5a6ebf0396]
$ keyctl show
Session Keyring
1048296028 --alswrv   1000  1000  keyring: _ses
 615559430 --alsw-v   1000  1000   \_ logon: ext4:07a3ce5a6ebf0396

※パスフレーズの入力は1回だけで確認されないので初回は特に注意.利用しはじめる前にキーリングをクリアして登録し直してパスフレーズが正しいか確認しておく.

  • 暗号化ポリシーの設定

このとき対象ディレクトリが空ではない場合エラーとなる( Error [Directory not empty] setting policy. )ので注意.

マウントポイントにはlost+foundが存在するので必ずサブディレクトリ以下である必要がある.

$ mkdir /mnt/encryption
$ /usr/sbin/e4crypt set_policy 07a3ce5a6ebf0396 /mnt/encryption
Key with descriptor [07a3ce5a6ebf0396] applied to /mnt/encryption.

※鍵の生成とキーリングへの追加と暗号化ポリシーの設定は次のようにすることで一度に設定可能

$ /usr/sbin/e4crypt add_key /mnt/encryption
  • 暗号化ファイルシステム領域にファイルを作成
$ echo 'hello' > /mnt/encryption/test.txt
$ ls -la /mnt/encryption
合計 12
drwxr-xr-x 2 mk mk 4096  4月  2 05:07 .
drwxr-xr-x 4 mk mk 4096  4月  2 05:06 ..
-rw-r--r-- 1 mk mk    6  4月  2 05:07 test.txt
  • キーリングのクリア
$ sudo keyctl clear @s
$ sudo keyctl show
Session Keyring
1048296028 --alswrv   1000  1000  keyring: _ses

キーリングをクリアしただけではアクセスできる

$ ls -lA /mnt/encryption
合計 12
-rw-r--r-- 1 mk mk    6  4月  2 05:07 test.txt
  • アンマウントとマウントし直し

キーリングをクリアした状態でアンマウントすると暗号化された状態に戻る

$ sudo umount /mnt
$ sudo mount -o loop ./ext4-crypt.img /mnt
$ ls -la /mnt/encryption
合計 12
drwxr-xr-x 2 mk mk 4096  4月  2 05:42 .
drwxr-xr-x 4 mk mk 4096  4月  2 05:06 ..
-rw-r--r-- 1 mk mk    6  4月  2 05:42 uzUlJZQfaxMx,7cC63,53A
$ cat /mnt/encryption/uzUlJZQfaxMx,7cC63,53A 
cat: /mnt/encryption/uzUlJZQfaxMx,7cC63,53A: 要求されたキーが利用できません

ユーザ,グループ,パーミッションなどは見える.内容にはアクセスできない.

  • 再度暗号化領域を利用出来るようにする

鍵の生成とキーリングへの追加と暗号化ポリシーの設定をし直すとアクセスできるようになる

$ /usr/sbin/e4crypt add_key /mnt/encryption
Enter passphrase (echo disabled): 
Added key with descriptor [07a3ce5a6ebf0396]
$ ls -la /mnt/encryption
合計 12
drwxr-xr-x 2 mk mk 4096  4月  2 05:42 .
drwxr-xr-x 4 mk mk 4096  4月  2 05:06 ..
-rw-r--r-- 1 mk mk    6  4月  2 05:42 test.txt

ファイル名長の確認

EncFSなどはファイル名のメタデータがファイル名内にあるので利用できるファイル名長が短くなってしまう.ext4ではどうか試す.

  • 通常のext4領域では256文字
$ touch /mnt/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
touch: '/mnt/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456' に touch できません: ファイル名が長すぎます
$ touch /mnt/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
  • 暗号化領域も同様だった
$ touch /mnt/encryption/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
$ ls -lA /mnt/encryption/
合計 4
-rw-r--r-- 1 mk mk 0  4月  2 07:14 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
-rw-r--r-- 1 mk mk 6  4月  2 05:42 test.txt
  • 非暗号化状態ではこんな状態
-rw-r--r-- 1 mk mk    0  4月  2 07:14 _OsoePJvc3qPQCPHbUMtjSynszcHig3BL
-rw-r--r-- 1 mk mk    6  4月  2 05:42 uzUlJZQfaxMx,7cC63,53A

復号状態のファイル名は別の場所に記録されているよう.

複数の暗号化領域を作ってみる

  • 新しい暗号化領域のためのディレクトリを作成
$ mkdir /mnt/encryption2
$ ls -la /mnt/encryption2
合計 8
drwxr-xr-x 2 mk mk 4096  4月  2 06:49 .
drwxr-xr-x 5 mk mk 4096  4月  2 06:49 ..
  • 暗号化設定
$ sudo e4crypt add_key /mnt/encryption2
Enter passphrase (echo disabled):
Key with descriptor [9640dd016062b432] already exists
Key with descriptor [9640dd016062b432] applied to /mnt/encryption2.
$ keyctl show
Session Keyring   
1048296028 --alswrv   1000  1000  keyring: _ses
  94779002 --alsw-v      0     0   \_ logon: ext4:69ca01e214957173
 219437542 --alsw-v      0     0   \_ logon: ext4:07a3ce5a6ebf0396
1025344233 --alsw-v      0     0   \_ logon: ext4:9640dd016062b432
$ touch /mnt/encryption2/hoge
  • 一回暗号化を解除してマウントし直す
$ keyctl clear @s
$ keyctl show
Session Keyring   
1048296028 --alswrv   1000  1000  keyring: _ses
$ sudo umount /mnt
$ sudo mount -o loop ./ext4-crypt.img /mnt
  • 片方だけ鍵を登録して暗号化領域を利用
$ sudo e4crypt add_key /mnt/encryption2
Enter passphrase (echo disabled):
Added key with descriptor [9640dd016062b432]
Key with descriptor [9640dd016062b432] applied to /mnt/encryption2.
$ ls -la /mnt/encryption*
/mnt/encryption:  
合計 12
drwxr-xr-x 2 mk mk 4096  4月  2 06:11 .
drwxr-xr-x 5 mk mk 4096  4月  2 06:49 ..
-rw-r--r-- 1 mk mk    0  4月  2 06:11 _OsoePJvc3qPQCPHbUMtjSynszcHig3BL
-rw-r--r-- 1 mk mk    6  4月  2 05:42 uzUlJZQfaxMx,7cC63,53A

/mnt/encryption2: 
合計 8
drwxr-xr-x 2 mk mk 4096  4月  2 06:51 .
drwxr-xr-x 5 mk mk 4096  4月  2 06:49 ..
-rw-r--r-- 1 mk mk    0  4月  2 06:51 hoge

暗号化領域に鍵が登録されてない状態でファイルを作ってみる

暗号化領域に鍵が登録されてない状態でファイルを作るとどうなるかを確認.

$ ls -lA /mnt/encryption
合計 4
-rw-r--r-- 1 mk mk 0  4月  2 07:14 _OsoePJvc3qPQCPHbUMtjSynszcHig3BL
-rw-r--r-- 1 mk mk 6  4月  2 05:42 uzUlJZQfaxMx,7cC63,53A
mk@x220:~ (1180)$ touch /mnt/encryption/test
touch: '/mnt/encryption/test' のタイムスタンプを設定中です: そのようなファイルやディレクトリはありません
mk@x220:~ (1181)$ ls -lA /mnt/encryption
合計 4
-rw-r--r-- 1 mk mk 0  4月  2 07:14 _OsoePJvc3qPQCPHbUMtjSynszcHig3BL
-rw-r--r-- 1 mk mk 6  4月  2 05:42 uzUlJZQfaxMx,7cC63,53A

エラーとなって作れない.

別のユーザで利用

  • 別のユーザで中が見えるか確認
$ id
uid=1001(gm) gid=1001(gm) groups=1001(gm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(netdev)
$ ls -la /mnt/encryption
合計 12
drwxr-xr-x 2 mk mk 4096  4月  2 06:11 .
drwxr-xr-x 7 mk mk 4096  4月  2 07:48 ..
-rw-r--r-- 1 mk mk    0  4月  2 07:14 _OsoePJvc3qPQCPHbUMtjSynszcHig3BL
-rw-r--r-- 1 mk mk    6  4月  2 05:42 uzUlJZQfaxMx,7cC63,53A
$ ls -la /mnt/encryption
合計 12
drwxrwxrwx 2 mk mk 4096  4月  2 06:11 .
drwxr-xr-x 7 mk mk 4096  4月  2 07:48 ..
-rw-r--r-- 1 mk mk    0  4月  2 07:14 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
-rw-r--r-- 1 mk mk    6  4月  2 05:42 test.txt
  • 権限があればファイル作成もできる
$ touch /mnt/encryption/other_user
$ ls -lA /mnt/encryption
合計 4
-rw-r--r-- 1 mk mk 0  4月  2 07:14 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
-rw-r--r-- 1 gm gm 0  4月  2 07:55 other_user
-rw-r--r-- 1 mk mk 6  4月  2 05:42 test.txt
  • 暗号化解除は出来ないと思ったが,
$ /usr/sbin/e4crypt add_key /mnt/encryption
/mnt/encryption: Permission denied
  • パーミッションをゆるくしてやると出来てしまう.
$ ls -la /mnt/encryption
合計 12
drwxrwxrwx 2 mk mk 4096  4月  2 07:55 .
drwxr-xr-x 7 mk mk 4096  4月  2 07:48 ..
-rw-r--r-- 1 gm gm    0  4月  2 07:55 97NmIBETx,1q9US96etRsA
-rw-r--r-- 1 mk mk    0  4月  2 07:14 _OsoePJvc3qPQCPHbUMtjSynszcHig3BL
-rw-r--r-- 1 mk mk    6  4月  2 05:42 uzUlJZQfaxMx,7cC63,53A
$ /usr/sbin/e4crypt add_key /mnt/encryption
Enter passphrase (echo disabled): 
Added key with descriptor [07a3ce5a6ebf0396]
Error [Permission denied] setting policy.
The key descriptor [07a3ce5a6ebf0396] may not match the existing encryption context for directory [/mnt/encryption].
$ ls -lA /mnt/encryption
合計 4
-rw-r--r-- 1 mk mk 0  4月  2 07:14 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
-rw-r--r-- 1 gm gm 0  4月  2 07:55 other_user
-rw-r--r-- 1 mk mk 6  4月  2 05:42 test.txt

]]>
https://matoken.org/blog/2017/04/02/try-ext4-encryption-file-system/feed/ 0
DebianのisoイメージをUSBメモリに書き込み https://matoken.org/blog/2017/03/29/write-debian-iso-image-to-usb-memory/ https://matoken.org/blog/2017/03/29/write-debian-iso-image-to-usb-memory/#respond Wed, 29 Mar 2017 09:08:17 +0000 http://matoken.org/blog/?p=1576 gistに貼ってたものだけどせっかくなのでこちらにも.

ファイルダウンロード

今回はDebian stretch Debian Installer rc2のi386版のnetinst.

  • debian-stretch-DI-rc2-i386-netinst.iso : イメージ本体
  • SHA512SUMS : isoファイルのチェックサムファイル
  • SHA512SUMS.sign : SHA512SUMSの署名ファイル
$ wget http://cdimage.debian.org/cdimage/stretch_di_rc2/i386/iso-cd/debian-stretch-DI-rc2-i386-netinst.iso http://cdimage.debian.org/cdimage/stretch_di_rc2/i386/iso-cd/SHA512SUMS.sign http://cdimage.debian.org/cdimage/stretch_di_rc2/i386/iso-cd/SHA512SUMS

※i386/amd64をよく使う場合はmulti-archを使うと1つのUSBメモリでi386/amd64が利用できて便利

チェックサムファイルの署名確認

チェックサムファイルのSHA512SUMSが正常なものか確認

$ gpg --verify SHA512SUMS.sign
gpg: 署名されたデータが'SHA512SUMS'にあると想定します
gpg: 2017年02月02日 07時45分30秒 JSTに施された署名
gpg:                RSA鍵DA87E80D6294BE9Bを使用
gpg: "Debian CD signing key <debian-cd@lists.debian.org>"からの正しい署名 [不明の]
gpg: *警告*: この鍵は信用できる署名で証明されていません!
gpg:       この署名が所有者のものかどうかの検証手段がありません。
 主鍵フィンガープリント: DF9B 9C49 EAA9 2984 3258  9D76 DA87 E80D 6294 BE9B

公開鍵が見つかりません(public key not found)というエラーの場合はgpg --keyserver keyring.debian.org --recv-keys DA87E80D6294BE9Bで鍵をインポートして再度確認.鍵のIDやフィンガープリントは以下のページでも確認できる

ハッシュ確認

isoファイルが正しくダウンロードされているか確認
以下の例はdebian-stretch-DI-rc2-i386-netinst.isoしかダウンロードしていないのでそれ以外のエラーや警告は無視する

$ sha512sum -c SHA512SUMS
sha512sum: debian-mac-stretch-DI-rc2-i386-netinst.iso: そのようなファイルやディレクトリはありません
debian-mac-stretch-DI-rc2-i386-netinst.iso: FAILED open or read
debian-stretch-DI-rc2-i386-netinst.iso: 完了
sha512sum: debian-stretch-DI-rc2-i386-xfce-CD-1.iso: そのようなファイルやディレクトリはありません
debian-stretch-DI-rc2-i386-xfce-CD-1.iso: FAILED open or read
sha512sum: 警告: 一覧にある 2 個のファイルが読み込めませんでした

usbメモリへの書き込み

USBメモリの確認

書き込み先のデバイスが正しいか確認する
USBメモリ接続直後にdmesgを確認したりfdiskコマンドやマウントして中を確認したり……

$ dmesg
  :
[414356.444121] usb 1-1.2: New USB device found, idVendor=13fe, idProduct=1a00
[414356.444128] usb 1-1.2: New USB device strings: Mfr=0, Product=11, SerialNumber=0
[414356.444131] usb 1-1.2: Product: USB 2.0 HUB
[414362.925178] usb-storage 1-1.2.1:1.0: USB Mass Storage device detected
[414362.925967] scsi host6: usb-storage 1-1.2.1:1.0
[414364.184209] sd 6:0:0:1: [sdb] 980480 512-byte logical blocks: (502 MB/479 MiB)
[414364.187102] sd 6:0:0:1: [sdb] Write Protect is off
[414364.187106] sd 6:0:0:1: [sdb] Mode Sense: 23 00 00 00
[414364.190339] sd 6:0:0:1: [sdb] No Caching mode page found
[414364.190345] sd 6:0:0:1: [sdb] Assuming drive cache: write through
[414364.201730]  sdb: sdb1
[414364.201734] sdb: p1 size 982496 extends beyond EOD, enabling native capacity
[414364.214471]  sdb: sdb1
[414364.214475] sdb: p1 size 982496 extends beyond EOD, truncated
[414364.228961] sd 6:0:0:1: [sdb] Attached SCSI removable disk
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 478.8 MiB, 502005760 bytes, 980480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start    End Sectors   Size Id Type
/dev/sdb1  *       32 982527  982496 479.8M  6 FAT16

USBメモリのアンマウント

USBメモリをマウントしている場合はアンマウントしておく

$ sudo umount /dev/sdb1
$ mount | grep /dev/sdb

パーテイション情報の削除

念の為パーテイション情報を削除しておく

$ sudo wipefs /dev/sdb
offset               type
----------------------------------------------------------------
0x1fe                dos   [partition table]

$ sudo wipefs -a /dev/sdb ; sync
/dev/sdb: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sdb: calling ioctl to re-read partition table: 成功です

書き込み

進捗状態を確認したい場合はpvコマンドを間に挟んだり,ddrescue / ddrescueなどが利用できる

$ sudo dd if=./debian-stretch-DI-rc2-i386-netinst.iso of=/dev/sdb bs=4M ; sync
95+1 レコード入力
95+1 レコード出力
401604608 bytes (402 MB, 383 MiB) copied, 176.874 s, 2.3 MB/s

書き込みが終わったらUSBメモリを取り外してターゲットマシンで利用する

VirtualBoxで起動確認(余録)

手軽に試せるマシンがなかったのでVirtualBoxからUSBメモリを起動して確認した

USBメモリのディスクイメージ作成

直にUSBメモリを指定できないのでUSBメモリへアクセスするためのvmdkイメージを作成

$ sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/sdb -filename sdb.vmdk 
RAW host disk access VMDK file sdb.vmdk created successfully.
$ sudo cat sdb.vmdk
# Disk DescriptorFile
version=1
CID=1722e641
parentCID=ffffffff
createType="fullDevice"

# Extent description
RW 980480 FLAT "/dev/sdb" 0

# The disk Data Base 
#DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="972"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.uuid.image="c2c9d560-049f-4c44-bf8a-0b85e820ba12"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"

USBメモリにアクセス権のあるユーザでVirtualBoxを起動してUSBメモリのイメージを指定して起動

(ここいまいち……)

$ gksudo virtualbox

]]>
https://matoken.org/blog/2017/03/29/write-debian-iso-image-to-usb-memory/feed/ 0
mikutterからGooglePhotosにアップロードするやつを試す https://matoken.org/blog/2017/03/01/try-mikutter-google-photos-uploader/ https://matoken.org/blog/2017/03/01/try-mikutter-google-photos-uploader/#respond Tue, 28 Feb 2017 23:51:39 +0000 http://matoken.org/blog/?p=1544

というわけで、mikutterのプラグインできた。 https://t.co/6hP23pBziO

— スラマイマラス (@slimymars) 2017年2月25日

Google Photosってことは容量気にせず画像投げられる & Google+との連携もできそう?ってことで試してみました.

#mikutterについてはこちらを.

関連パッケージ導入

$ sudo apt install ruby-oauth2

mikutter-google-photos-uploader plugin導入

$ cd ~/.mikutter/plugin
$ git clone https://github.com/slimymars/mikutter-google-photos-uploader
$ cd mikutter-google-photos-uploader
$ bundle install

mikutter起動

……認識されない.mikutterが古い所為のようです.

$ grep mikutter: ~/.mikutter/plugin/mikutter-google-photos-uploader/.mikutter.yml 
  mikutter: 3.5.2
$ dpkg-query -W mikutter
mikutter        3.5.0+dfsg-1

Debianではjessie-backportsからsidまで3.5.0+dfsg-1experimentalだけ3.5.2+dfsg-1でした.

てことで,experimentalから借りてきます.

sources.listexperimentalがある状態で

$ grep experimental /etc/apt/sources.list
deb http://dennou-q.gfd-dennou.org/debian/ experimental main non-free contrib
deb-src http://dennou-q.gfd-dennou.org/debian/ experimental main non-free contrib

/etc/apt/preferences.d/mikutterを以下のような感じで用意して,

$ cat /etc/apt/preferences.d/mikutter
Package: mikutter
Pin: release a=experimental
Pin-Priority: 800

パッケージを更新して導入.

$ sudo apt upgrade

mikutterでの設定

mikutterが3.5.2になったので認識しました.設定画面を見ると,GooglePhotosというタブが増えているのでそのタブのAuthrise code 取得URLをブラウザで開いて認証し,出てきたコードをAuthrization_codeに貼り付けます.
更にmikutterからアップロードする保存先のアルバムを追加しておきます.GooglePhotosに存在しないアルバムは前もって

から登録しておきましょう.アルバムは複数登録できるので例えば

  • ミク
  • フレンズ

のようにアルバムを登録しておくと画像整理がはかどります?

20170228_19:02:23-16584

実際の画像保存方法は,mikutterの保存したい画像の上で右クリックしてGoogle Photosに画像をアップロードを選び,

shutter_17-03-01_08:33:12_001

その後表示されるアルバムを選択するだけです.

menu_018

Google Photosに見に行くとアップロードされているのが確認できます.

Google+へのクロスポストにも使えるかなと思ったのですが,Google+の投稿画面はタイムラグがあるようで少し待たないと表示されませんでした.これはGoogle側の問題ですね.Google Photosから投稿するようにすれば良さそうです.

関連?Tweet

環境

$ screenfetch
         _,met$$$$$gg.           mk@x220
      ,g$$$$$$$$$$$$$$$P.        OS: Debian 9.0 stretch
    ,g$$P""       """Y$$.".      Kernel: x86_64 Linux 4.9.0-2-amd64
   ,$$P'              `$$$.      Uptime: 4d 18h 51m
  ',$$P       ,ggs.     `$$b:    Packages: 5147
  `d$$'     ,$P"'   .    $$$     Shell: bash 4.4.11
   $$P      d$'     ,    $$P     Resolution: 1366x768
   $$:      $$.   -    ,d$$'     WM: Awesome
   $$\;      Y$b._   _,d$P'      WM Theme: default
   Y$$.    `.`"Y$$$$P"'          CPU: Intel Core i5-2540M CPU @ 3.3GHz
   `$$b      "-.__               GPU: Mesa DRI Intel(R) Sandybridge Mobile 
    `Y$$                         RAM: 13040MiB / 15934MiB
     `Y$$.                      
       `$$b.                    
         `Y$$b.                 
            `"Y$b._             
                `""""           
]]>
https://matoken.org/blog/2017/03/01/try-mikutter-google-photos-uploader/feed/ 0
Mumble server設定メモ https://matoken.org/blog/2017/01/26/mumble-server-setting-note/ https://matoken.org/blog/2017/01/26/mumble-server-setting-note/#respond Wed, 25 Jan 2017 17:42:07 +0000 http://matoken.org/blog/?p=1507 鹿児島Linux勉強会 2017.01の遠隔で利用した設定メモです.

  • サーバのOSはDebian jessie amd64
  • 自動起動せず利用時に手動で起動する
  • fwも都度手動
  • サブチャンネルはなし
  • ssl証明書は既存のstartsslを利用

pkgの導入

$ sudo apt install mumble-server

自動起動を無効にする

$ sudo dpkg-reconfigure mumble-server

で設定画面に入り,

Mumble-server (murmurd) can start automatically when the server is booted.

Autostart mumble-server on server boot?

を選択する.
(/etc/default/mumble-serverMURMUR_DAEMON_START=0でも)

設定ファイルを編集

diff --git a/mumble-server.ini b/mumble-server.ini
index b445d4e..46f1dfd 100644
--- a/mumble-server.ini
+++ b/mumble-server.ini
@@ -12,7 +12,7 @@
 #        NOT regex = \w* BUT regex = \\w*

 # Path to database. If blank, will search for
-# murmur.sqlite in default locations or create it if not found.
+A
 database=/var/lib/mumble-server/mumble-server.sqlite

 # If you wish to use something other than SQLite, you'll need to set the name
@@ -86,7 +86,7 @@ pidfile=/var/run/mumble-server/mumble-server.pid
 # configure it here ehan ehrough D-Bus or Ice.
 #
 # Welcome message sent to clients when they connect.
-welcometext="<br />Welcome to this server running <b>Murmur</b>.<br />Enjoy your stay!<br />"
+welcometext="<br />Welcome to KagoLUG server running <b>Murmur</b>.<br />Enjoy your stay!<br />"

 # Port to bind TCP and UDP sockets to.
 port=64738
@@ -144,26 +144,28 @@ users=100
 # addresses.
 # Only uncomment the 'registerName' parameter if you wish to give your "Root" channel a custom name.
 #
-#registerName=Mumble Server
+registerName=KagoLUG Mumble Server
 #registerPassword=secret
 #registerUrl=http://mumble.sourceforge.net/
-#registerHostname=
+registerHostname=kagolug.org

 # If this option is enabled, the server will announce its presence via the 
 # bonjour service discovery protocol. To change the name announced by bonjour
 # adjust the registerName variable.
 # See http://developer.apple.com/networking/bonjour/index.html for more information
 # about bonjour.
-#bonjour=True
+bonjour=False

 # If you have a proper SSL certificate, you can provide the filenames here.
 # Otherwise, Murmur will create it's own certificate automatically.
-#sslCert=
-#sslKey=
+#sslCert=/etc/letsencrypt/live/kagolug.org/cert.pem
+sslCert=/etc/letsencrypt/live/kagolug.org/fullchain.pem
+sslKey=/etc/letsencrypt/live/kagolug.org/privkey.pem
+#sslCA=/etc/letsencrypt/live/kagolug.org/fullchain.pem

 # If Murmur is started as root, which user should it switch to?
 # This option is ignored if Murmur isn't started with root privileges.
-uname=mumble-server
+uname=root

 # If this options is enabled, only clients which have a certificate are allowed
 # to connect.

ssl証明書をクリア

$ sudo murmurd -wipessl
$ sudo killall murmurd

利用時

デーモンの起動とポート開放を行う

$ sudo service mumble-server start
$ sudo iptables -A INPUT -p udp -m udp --dport 64738 -j ACCEPT
$ sudo iptables -A INPUT -p tcp -m tcp --dport 64738 -j ACCEPT

利用者にはサーバとポートを伝える
– server : kagolug.org
– port : 64738

mumble://kagolug.org?title=KagoLUG%20Mumble%20Server&version=1.2.0

利用環境

  • PC : ThinkPad X200(Ubuntu 16.10 amd64)
  • マイク : elecom製の数百円のもの
  • スピーカー : Elecom LBT-SPTR01ECBK

はじめLBT-SPTR01ECBKでマイクとスピーカー両方の役割をと思っていたが,うまく音を拾えない&HSP/HFPでは音が悪く聞き取りづらかったので役割を分けた.
マイクはPC直付だったので音を拾いづらい&キー入力の音などを拾っていたはず.

利用完了時

デーモンの終了

$ sudo service mumble-server start

iptablesのmumbleルールを閉じる

$ sudo iptables -L --line-numbers | grep 64738
23   ACCEPT     udp  --  anywhere             anywhere             udp dpt:64738
24   ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:64738
$ sudo iptables -D INPUT 23
$ sudo iptables -D INPUT 24
$ sudo iptables -L --line-numbers | grep 64738

課題

ssl証明書ファイルを読み込むためにdaemonをrootで動かしているのをmumble-serverユーザに戻したい.

-uname=mumble-server
+uname=root
$ sudo ls -l /etc/letsencrypt/live/kagolug.org/fullchain.pem /etc/letsencrypt/live/kagolug.org/privkey.pem
lrwxrwxrwx 1 root ssl-cert 40 Dec 26 10:30 /etc/letsencrypt/live/kagolug.org/fullchain.pem -> ../../archive/kagolug.org/fullchain9.pem
lrwxrwxrwx 1 root ssl-cert 38 Dec 26 10:30 /etc/letsencrypt/live/kagolug.org/privkey.pem -> ../../archive/kagolug.org/privkey9.pem

ssl-certグループにmumble-serverを登録で行けそう?

マイク

会議向けの全方位のマイクが欲しい

]]>
https://matoken.org/blog/2017/01/26/mumble-server-setting-note/feed/ 0
Screenfetch的な情報表示コマンドのNeofetch https://matoken.org/blog/2016/12/07/screenfetch-like-information-display-command-neofetch/ https://matoken.org/blog/2016/12/07/screenfetch-like-information-display-command-neofetch/#respond Tue, 06 Dec 2016 21:27:09 +0000 http://matoken.org/blog/?p=1476 Screenfetch的な情報表示コマンドのNeofetch

よくデスクトップのキャプチャを取得するときに表示されているScreenfetchコマンドというものがあります.システムの情報とアスキーアートを素敵に表示してくれます. これににたものでNetfetchというものを見かけたので試してみました.こちらは画像も扱えるようです.

導入

以下のページに各種環境への導入方法が書かれています.

Debian sid/stretchにはパッケージがあるようなことが書かれていますが,

Neofetch is in Debian Unstable/Stretch's official repositories.

今はsidのみのようです.

ということでひとまずstretchではこんな感じで導入しました.

$ #-- /etc/apt/sources.list.d/neofetch を作る
$ sudo apt edit-sources neofetch
$ cat /etc/apt/sources.list.d/neofetch.list
deb http://dl.bintray.com/dawidd6/neofetch jessie main
$ #-- 鍵のインポート
$ wget "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" -O Release-neofetch.key
$ gpg Release-neofetch.key
pub   rsa4096 2015-02-17 [SC]
      8756C4F765C9AC3CB6B85D62379CE192D401AB61
uid           Bintray (by JFrog) <bintray@bintray.com>
sub   rsa4096 2015-02-17 [E]
$ sudo apt-key add Release-neofetch.key
$ rm Release-neofetch.key
$ #-- pkg情報更新&pkg導入
$ sudo apt update
$ sudo apt install neofetch

早速実行

$ neofetch --help

    NEOFETCH

    USAGE: neofetch --option "value" --option "value"

    NOTE: There's also a config option for each flag below.

    Info:
    --disable infoname          Allows you to disable an info line from appearing
                                in the output.
                                NOTE: You can supply multiple args. eg.
                                'neofetch --disable cpu gpu disk shell'
                                NOTE: The arguments must all be lowercase.
    --os_arch on/off            Hide/Show OS architecture.
    --speed_type type           Change the type of cpu speed to display.
                                Possible values: current, min, max, bios,
                                scaling_current, scaling_min, scaling_max
                                NOTE: This only support Linux with cpufreq.
    --cpu_shorthand type        Shorten the output of CPU
                                Possible values: name, speed, tiny, on, off
    --cpu_cores type            Whether or not to display the number of CPU cores
                                Takes: logical, physical, off
                                NOTE: 'physical' doesn't work on BSD.
    --cpu_speed on/off          Hide/Show cpu speed.
    --cpu_temp on/off           Hide/Show cpu temperature.
                                NOTE: This only works on Linux and BSD.
                                NOTE: For FreeBSD-based systems, you need to enable coretemp
                                      kernel module.
    --distro_shorthand on/off   Shorten the output of distro (tiny, on, off)
                                NOTE: This option won't work in Windows (Cygwin)
    --kernel_shorthand on/off   Shorten the output of kernel
                                NOTE: This option won't work in BSDs (except PacBSD and PC-BSD)
    --uptime_shorthand on/off   Shorten the output of uptime (tiny, on, off)
    --refresh_rate on/off       Whether to display the refresh rate of each monitor
                                Unsupported on Windows
    --gpu_brand on/off          Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
    --gtk_shorthand on/off      Shorten output of gtk theme/icons
    --gtk2 on/off               Enable/Disable gtk2 theme/icons output
    --gtk3 on/off               Enable/Disable gtk3 theme/icons output
    --shell_path on/off         Enable/Disable showing $SHELL path
    --shell_version on/off      Enable/Disable showing $SHELL version
    --ip_host url               Url to query for public IP
    --song_shorthand on/off     Print the Artist/Title on seperate lines
    --birthday_shorthand on/off Shorten the output of birthday
    --birthday_time on/off      Enable/Disable showing the time in birthday output
    --birthday_format format    Format the birthday output. (Uses 'date' cmd format)

    Text Formatting:
    --colors x x x x x x        Changes the text colors in this order:
                                title, @, underline, subtitle, colon, info
    --underline on/off          Enable/Disable the underline.
    --underline_char char       Character to use when underlining title
    --bold on/off               Enable/Disable bold text

    Color Blocks:
    --color_blocks on/off       Enable/Disable the color blocks
    --block_width num           Width of color blocks in spaces
    --block_height num          Height of color blocks in lines
    --block_range start end     Range of colors to print as blocks

    Bars:
    --bar_char 'elapsed char' 'total char'
                                Characters to use when drawing bars.
    --bar_border on/off         Whether or not to surround the bar with '[]'
    --bar_length num            Length in spaces to make the bars.
    --bar_colors num num        Colors to make the bar.
                                Set in this order: elapsed, total
    --cpu_display mode          Bar mode.
                                Takes: bar, infobar, barinfo, off
    --memory_display mode       Bar mode.
                                Takes: bar, infobar, barinfo, off
    --battery_display mode      Bar mode.
                                Takes: bar, infobar, barinfo, off
    --disk_display mode         Bar mode.
                                Takes: bar, infobar, barinfo, off

    Image:
    --image type                Image source. Where and what image we display.
                                Possible values: wall, ascii,
                                /path/to/img, /path/to/dir/, off
    --size 00px | --size 00%    How to size the image.
                                Possible values: auto, 00px, 00%, none
    --crop_mode mode            Which crop mode to use
                                Takes the values: normal, fit, fill
    --crop_offset value         Change the crop offset for normal mode.
                                Possible values: northwest, north, northeast,
                                west, center, east, southwest, south, southeast

    --xoffset px                How close the image will be to the left edge of the
                                window. This only works with w3m.
    --yoffset px                How close the image will be to the top edge of the
                                window. This only works with w3m.
    --bg_color color            Background color to display behind transparent image.
                                This only works with w3m.
    --gap num                   Gap between image and text.
                                NOTE: --gap can take a negative value which will
                                move the text closer to the left side.
    --clean                     Delete cached files and thumbnails.

    Ascii:
    --ascii value               Where to get the ascii from, Possible values:
                                distro, /path/to/ascii
    --ascii_colors x x x x x x  Colors to print the ascii art
    --ascii_distro distro       Which Distro's ascii art to print
                                NOTE: Arch and Ubuntu have 'old' logo varients.
                                NOTE: Use 'arch_old' or 'ubuntu_old' to use the old logos.
                                NOTE: Ubuntu has flavor varients.
                                NOTE: Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu-GNOME'
                                or 'Ubuntu-Budgie' to use the flavors.
    --ascii_logo_size           Size of ascii logo.
                                Supported distros: Arch, Gentoo, Crux, OpenBSD.
    --ascii_bold on/off         Whether or not to bold the ascii logo.
    --logo | -L                 Hide the info text and only show the ascii logo.

    Screenshot:
    --scrot | -s /path/to/img   Take a screenshot, if path is left empty the screen-
                                shot function will use $scrot_dir and $scrot_name.
    --upload | -su /pth/t/img   Same as --scrot but uploads the scrot to a website.
    --image_host                Website to upload scrots to. Takes: imgur, teknik
    --scrot_cmd cmd             Screenshot program to launch

    Other:
    --config /path/to/config    Specify a path to a custom config file
    --config none               Launch the script without a config file
    --help                      Print this text and exit
    --version                   Show neofetch version
    -v                          Display error messages.
    -vv                         Display a verbose log for error reporting.

オプション結構多いです. とりあえず素で実行.

20161207_05:12:12-5188

情報もScreenfetchより増えています.

20161207_05:12:20-9093

次は画像を指定してみます.画像サイズが大きかったので25%に縮小もしています. 楽しい :)

20161207_05:12:35-3963

20161207_06:12:30-16979

画像の表示については環境によってうまく行く行かないがあるようです.うまく表示されない場合は以下のWikiを参照すると良さそうです.

]]>
https://matoken.org/blog/2016/12/07/screenfetch-like-information-display-command-neofetch/feed/ 0
Mumbleでリモート会議 https://matoken.org/blog/2016/12/03/remote-conference-with-mumble/ https://matoken.org/blog/2016/12/03/remote-conference-with-mumble/#respond Fri, 02 Dec 2016 16:53:14 +0000 http://matoken.org/blog/?p=1461

先週ですが,FSIJ 月例会に参加していました. といっても東京に出て行ったわけではなくネットワーク開催だったので家からの参加です.

ということでMumbleというソフトウェアで音声チャット + Etherpad(ウェブブラウザベース)でテキスト交換という環境でした. Mumbleを前もって試していればよかったのだけど直前に入れてなかなか参加できず途中からの参加になりましたorz~

MumbleはDebian stretch amd64環境ではパッケージが存在する( mumble )のでこれを導入するだけでした.マルチプラットホームで各種環境向けにも存在して,Androidなどでも利用できるようです. – Mumble, the open source VoIP solutionPlumble – Mumble VOIP (Free) – Google Play の Android アプリPlumble – Mumble VOIP – Google Play の Android アプリ

今回使用機器は以下のような感じ.でしたが,スピーカーは試行錯誤している時に繋いだもので後で試すと本体のスピーカーで大丈夫でした.

  • PC : Thinkpad X220(Debian stretch amd64)
  • マイク : 3.5mmジャックに直接挿せるもの(型番不明)
  • スピーカー : ELECOM LBT-SPTR01AV(Bluetooth)

このときMumble利用時に嵌ったところをメモしておきます. – ヘッドホンとマイクが1つの端子の端末でマイクを繋ぐとヘッドホンもそちらを向いてしまって音が出なかった – Bluetothヘッドセットを繋ぐとそちらから音が出るようになったがマイクがうまく働かない – PulseAudio Volume Control (pavucontrol)で見るとマイクがミュートになっていたので解除してMumbleに割り当て – 伝送方式を"push to talk"にしたがpushがわからなかった -> ショートカットで適当なキーに割り当て(Mumble非アクティブ時も有効)

  • その他
    • Awesome WM環境ではMumbleが最小化してしまうと窓を復帰させる方法が今のところわからない.タスクトレイのアイコンをクリックしても出てこない.(Xfce4はアイコンクリックで出てくるよう)
    • 一回設定できればフォーカスがなくてもショートカットが効いて話せるのでとりあえず使えるけどチャットと誰が話しているかのアイコンの確認(唇アイコンが赤くなる)が出来ない(オーバーレイの設定でどうにかなりそう?)
    • アイコンを右クリックしてそのまま離すと丁度終了になってしまう…….
    • Mumbleの音声品質は16kbps/40kbps/72kbpsから選択可能(規定値は40k)
    • push to talkを使うとその時しか音声が飛ばないので周りの環境に左右されにくくて良い(キー入力の音や環境音が入りにくい)

最近はUstream.tv/Youtube Liveなどの動画配信やBBB(BigBlueButton)などの動画を使ったオンライン会議システムなどで中継ということが多いですが,手弁当の勉強会なんかだと回線などの問題でうまく行かなかったりすることが多いですが割り切って音声のみの中継にしてしまうのもありだなと感じました.

最近リモート参加した勉強会

]]>
https://matoken.org/blog/2016/12/03/remote-conference-with-mumble/feed/ 0
不正なUSBデバイスからPCを守るUSBGuardを試す https://matoken.org/blog/2016/10/08/try-usbguard-to-protect-the-pc-from-unauthorized-usb-device/ https://matoken.org/blog/2016/10/08/try-usbguard-to-protect-the-pc-from-unauthorized-usb-device/#respond Fri, 07 Oct 2016 17:38:50 +0000 http://matoken.org/blog/?p=1439 BadUSBなどの不正なUSBデバイスからPCが守れないかなちょっと設定すればできそう?そもそも作っている人がいるんじゃ?ということで探したらUSBGuardというソフトウェアを見つけました.

このソフトウェアを導入しておくと,設定したルールに合致しないUSBデバイスはblockされます. デスクトップ利用の場合はGUIのアプレットを利用してUSB接続時にウィンドウがポップアップして接続するか選べたりもします. 便利.
#USB KILLERは……USB配線を外したりUSBコネクタを塞ぐしかないですよね多分.

導入

Debian/Ubuntuにはパッケージがあるのでそちらから導入します.

$ sudo apt install usbguard usbguard-applet-qt

設定

一般ユーザから利用する場合は設定ファイルを編集してユーザかグループを追加してデーモンの再起動を行います. 設定ファイルは/etc/usbguard/usbguard-daemon.confです.

diff --git a/usbguard/usbguard-daemon.conf b/usbguard/usbguard-daemon.conf
index 4a54ca0..7b3a165 100644
--- a/usbguard/usbguard-daemon.conf
+++ b/usbguard/usbguard-daemon.conf
@@ -65,7 +65,7 @@ PresentControllerPolicy=keep
#
# IPCAllowedUsers=username1 username2 ...
#
-IPCAllowedUsers=root
+IPCAllowedUsers=root user1 user2

#
# Groups allowed to use the IPC interface.
@@ -75,7 +75,7 @@ IPCAllowedUsers=root
#
# IPCAllowedGroups=groupname1 groupname2 ...
#
-IPCAllowedGroups=root
+IPCAllowedGroups=root users

#
# Generate device specific rules including the "via-port"

ユーザの場合はIPCAllowedUsers,グループの場合はIPCAllowedGroupsにスペース区切りで書いていきます.

デーモンの再起動

設定を反映するためにデーモンを再起動します.

$ sudo service usbguard restart

CUIでの利用例

usbguardが起動した後に接続されたデバイスはblockされています.

$ usbguard list-devices| tail -2
9: allow id 8087:0024 serial "" name "" hash "Zx7v0FMQEjScKSAFENAiobEs1OGPPB0YWR+yXDCVE04=" parent-hash "WwvSEwd+7257rAqUGLMQjffF7zyqygmmLeQTYnR9QzQ=" via-port "4-1" with-interface 09:00:00
11: block id 1004:631c serial "03a809c94b4befd4" name "LGE Android Phone" hash "P5dSK5xxK4R5QTRzd7KlD8Agf/+28pztL077j1oWqPI=" parent-hash "Zx7v0FMQEjScKSAFENAiobEs1OGPPB0YWR+yXDCVE04=" via-port "4-1.1" with-interface ff:ff:00

blockされている11番目のデバイスを許可してみます.(これは一時的です)

$ usbguard allow-device 11
$ usbguard list-devices| tail -1
11: allow id 1004:631c serial "03a809c94b4befd4" name "LGE Android Phone" hash "P5dSK5xxK4R5QTRzd7KlD8Agf/+28pztL077j1oWqPI=" parent-hash "Zx7v0FMQEjScKSAFENAiobEs1OGPPB0YWR+yXDCVE04=" via-port "4-1.1" with-interface ff:ff:00

状況の確認

USBデバイスの認識状況を監視します.

$ usbguard watch
[IPC] Connected
[device] Inserted: id=12 hash=vi38heJ4vKEdayxiqrQFylpwa3xkVYYUkZi2zbu3sWs= name=Mass Storage Device product_id=1336 serial=00000000000006 vendor_id=048d interface={ 08:06:50} rule_match=0 rule_id=4294967295
[device] Blocked: id=12 name=Mass Storage Device product_id=1336 vendor_id=048d rule_match=0 rule_id=4294967295
[device] Allowed: id=12 name=Mass Storage Device product_id=1336 vendor_id=048d rule_match=0 rule_id=4294967295

GUI(usbguard-applet-qt)の利用例

CUIだとちょっと面倒ですが,デスクトップ利用の場合はusbguard-applet-qtが便利です.

usbguard-applet-qtが起動した状態でUSBデバイスを接続すると以下のようなダイヤログが表示されます.Allowボタンを押すことで利用できるようになります. このとき,Make the decision permanentにチェックを入れておくと,設定が永続化されます.この設定は/etc/usbguard/rules.confに記録されます.

20161007_02:10:22-9078

ダイヤログはタイムアウトすると消えてしまいますが,アプレットのウィンドウから設定画面を呼び出すことができます.ここから設定変更ができます.

20161007_16:10:49-4107

とりあえずはこれくらいで良さそうですが,ルールを書くといろいろ応用が効きそうです.

とりあえずはどうもデーモン起動までに接続されていたデバイスは許可されるようなので内臓デバイスを明示的に許可してその他をblockしようと思います.

]]>
https://matoken.org/blog/2016/10/08/try-usbguard-to-protect-the-pc-from-unauthorized-usb-device/feed/ 0
mind mappingアプリのFreeplaneを試す https://matoken.org/blog/2016/10/05/mind-mapping%e3%82%a2%e3%83%97%e3%83%aa%e3%81%aefreeplane%e3%82%92%e8%a9%a6%e3%81%99/ https://matoken.org/blog/2016/10/05/mind-mapping%e3%82%a2%e3%83%97%e3%83%aa%e3%81%aefreeplane%e3%82%92%e8%a9%a6%e3%81%99/#comments Tue, 04 Oct 2016 19:14:18 +0000 http://matoken.org/blog/?p=1437 FreeMindをDebian jessieに導入しようとしたらパッケージが見当たりません. 探してみるとメンテナンスされてないからjessie/sidから消されたようです.

We have Freeplane which is actively maintained and roughly equivalent in features.

でもFreeplaneというメンテされている似たものがあるよということでこれを試してみることにしました.

#ちなみにFreeMindのsiteを見るとstableのリリースが2013年で1.0.1.その後1.1.0-Beta1が2015年1.1.0-Beta2が2016年に出ていて,Debianでは0.9.0だったようです.

FreeplaneはどうもFreeMindのフォークのようです.見た目も使い勝手も似ています.JAVA製でマルチプラットホームなのも同じです.

導入はパッケージがあるのでそれを利用しました.

$ sudo apt install freeplane

起動ロゴ……何だろうこの虫?は.

20161005_01:10:30-30616

初回起動時にはWhats Newが表示されました.

20161005_01:10:09-30241

少し日本語が豆腐になってしまっている場所がありましたがフォントを日本語フォントに変更することで解決しました. 後はチュートリアルとかに目を通しておくと良さそうです.

チュートリアルなどのドキュメントは/usr/share/freeplane/doc/辺りにありました.

$ ls -1 /usr/share/freeplane/doc/*_ja.mm
/usr/share/freeplane/doc/freeplaneFunctions_ja.mm
/usr/share/freeplane/doc/freeplaneTutorial_ja.mm
/usr/share/freeplane/doc/freeplane_ja.mm

20161005_01:10:53-29876

20161005_01:10:09-28858

20161005_01:10:32-27112

未だそんなに使っていませんが,FreeMindと同じような操作性だし以前書いた.mmも読めるようなのでそのまま移行できそうです.

<追記>

Ubuntu 16.10 amd64(今は未だリリース前)にも入れてみましたが起動しませんでした.とりあえず本家から.zipを貰ってきて動かしています.一応報告はしてみました.

</追記>

]]>
https://matoken.org/blog/2016/10/05/mind-mapping%e3%82%a2%e3%83%97%e3%83%aa%e3%81%aefreeplane%e3%82%92%e8%a9%a6%e3%81%99/feed/ 2
Android端末をLinuxのタッチパッド替わりにしたい(Bluetooth利用のBlink) https://matoken.org/blog/2016/06/17/want-the-android-terminal-to-the-touch-pad-instead-of-linux-blink-of-bluetooth-use/ https://matoken.org/blog/2016/06/17/want-the-android-terminal-to-the-touch-pad-instead-of-linux-blink-of-bluetooth-use/#respond Fri, 17 Jun 2016 13:36:25 +0000 http://matoken.org/blog/?p=1394

最近またポインティングデバイスにApple Wireless Trackpadを利用するようになりましたが持ち運びには少し嵩張ります.マウスを持ち運ぶのもかさばります.
Ubuntu TouchでHDMI接続時にタッチデバイスになるというのを見てAndroid端末をタッチデバイスにすることが出来るのでは?それなら荷物増え無いしいいかもと思って少し調べてみました.

BlinkはBluetooth接続かつPC側でデーモンを動かす必要があります.
先ずBluetoothペアリングをしておき,PC側でデーモンを導入します.

  • 必要パッケージの導入

$ sudo apt install bluez python-bluez xdotoolsudo apt-get install bluez python-bluez xdotool
  • デーモンの導入

$ git clone https://github.com/drpain/blink-server.git ~/.blink

以下のようにしてデーモンを起動するのですが,この記事を書いている時点でのDebian stretch testing amd64では以下のようなエラーとなります.

$ sudo ~/.blink/bluetooth_server.py
Traceback (most recent call last):
  File "/home/mk/.blink/bluetooth_server.py", line 25, in <module>
    profiles         = [ SERIAL_PORT_PROFILE ]
  File "/usr/lib/python2.7/dist-packages/bluetooth/bluez.py", line 176, in advertise_service
    raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')

GuihubのHELPを参考に*/etc/bluetooth/main.conf*を以下のように修正します.

diff --git a/bluetooth/main.conf b/bluetooth/main.conf
index 372fd8c..2f7cc4a 100644
--- a/bluetooth/main.conf
+++ b/bluetooth/main.conf
@@ -64,6 +64,9 @@
 # 'false'.
 #FastConnectable = false

+# "drpain/blink-server: This is the server you would need to be able to run the Blink Android Application." https://github.com/drpain/blink-server
+DisablePlugins = pnat
+
 #[Policy]
 #
 # The ReconnectUUIDs defines the set of remote services that should try

設定を反映するためにbluetoothdを再起動してサーバを再起動します.

$ sudo service bluetooth restart

サーバは要rootのようです.
この状態でAndroid側からクライアントPCを選択して接続すればok.

$ sudo ~/.blink/bluetooth_server.py
READY FOR CONNECTIONS, RFCOMM channel 1
('INBOUND CONNECTION ', ('68:76:4F:3B:D1:E0', 1))
COMMAND RECEIVED [{"action":"mouse-move","x":null,"y":null}]
['xdotool', 'mousemove_relative', '--', 'None', 'None']
COMMAND RECEIVED [{"action":"mouse-move","x":-1,"y":0}]
['xdotool', 'mousemove_relative', '--', '-1', '0']
COMMAND RECEIVED [{"action":"mouse-move","x":0,"y":0}]
['xdotool', 'mousemove_relative', '0', '0']
COMMAND RECEIVED [{"action":"mouse-move","x":-1,"y":0}]
['xdotool', 'mousemove_relative', '--', '-1', '0']

上の方のモード切替スイッチをタップして規定の「Swipe Area」から「Mouse」にします.「Mouse Area」で操作するとxdotoolのログが大量に出つつ操作できます.

27629912281 e0ba729509 n
27094267013 3fb8577a76 n

操作は少し解りづらくてこんな感じです.

  • タップ→左クリック

  • タップ, ホールド, リリース → 右クリック

中クリックやドラッグは多分未実装で使えません.
カーソル移動はちらつきますがとりあえず使える感じです.

でも導入に要設定変更&要rootなのが面倒ですね.

]]>
https://matoken.org/blog/2016/06/17/want-the-android-terminal-to-the-touch-pad-instead-of-linux-blink-of-bluetooth-use/feed/ 0
awesomeとかでApple Wireless Trackpadを設定する https://matoken.org/blog/2016/06/17/to-set-the-apple-wireless-trackpad-at-awesomes/ https://matoken.org/blog/2016/06/17/to-set-the-apple-wireless-trackpad-at-awesomes/#respond Fri, 17 Jun 2016 13:31:36 +0000 http://matoken.org/blog/?p=1390

Bluetooth接続のApple Wireless Trackpadですが,GnomeとかだとBluetoothでペアリングした後こんな感じでGUIで設定できるのですが,

27082898093 594ed9ea4e n
27082898303 067a324e77 n
27414891970 2128414b0d n

awesomeだと効かないようです.ペアリングした後カーソル移動,2本指スクロール,右クリックはなどは動作するのですが,一番利用する左クリックが動作しません.

こいつはDynaptics driver用のコマンドのsynclientを使って設定内容の確認とアドホックな動作確認をします.
コマンドが存在しない場合 xserver-xorg-input-synaptics pkgを導入してください.
-l optionで設定項目の確認が出来ます.

$ synclient -l
Parameter settings:
    LeftEdge                = -2393
    RightEdge               = 2651
    TopEdge                 = -2030
    BottomEdge              = 2139
    FingerLow               = 70
    FingerHigh              = 75
    MaxTapTime              = 180
    MaxTapMove              = 346
    MaxDoubleTapTime        = 100
    SingleTapTimeout        = 180
    ClickTime               = 100
    EmulateMidButtonTime    = 0
    EmulateTwoFingerMinZ    = 100
    EmulateTwoFingerMinW    = 50
    VertScrollDelta         = 157
    HorizScrollDelta        = 157
    VertEdgeScroll          = 0
    HorizEdgeScroll         = 0
    CornerCoasting          = 0
    VertTwoFingerScroll     = 1
    HorizTwoFingerScroll    = 1
    MinSpeed                = 1
    MaxSpeed                = 1.75
    AccelFactor             = 0.0253743
    TouchpadOff             = 0
    LockedDrags             = 0
    LockedDragTimeout       = 5000
    RTCornerButton          = 0
    RBCornerButton          = 0
    LTCornerButton          = 0
    LBCornerButton          = 0
    TapButton1              = 0
    TapButton2              = 2
    TapButton3              = 3
    ClickFinger1            = 1
    ClickFinger2            = 3
    ClickFinger3            = 2
    CircularScrolling       = 1
    CircScrollDelta         = 0.1
    CircScrollTrigger       = 0
    CircularPad             = 0
    PalmDetect              = 1
    PalmMinWidth            = 10
    PalmMinZ                = 200
    CoastingSpeed           = 50
    CoastingFriction        = 50
    PressureMotionMinZ      = 30
    PressureMotionMaxZ      = 160
    PressureMotionMinFactor = 1
    PressureMotionMaxFactor = 1
    GrabEventDevice         = 0
    TapAndDragGesture       = 1
    AreaLeftEdge            = 0
    AreaRightEdge           = 0
    AreaTopEdge             = 0
    AreaBottomEdge          = 0
    HorizHysteresis         = 4
    VertHysteresis          = 4
    ClickPad                = 0
    RightButtonAreaLeft     = 0
    RightButtonAreaRight    = 0
    RightButtonAreaTop      = 0
    RightButtonAreaBottom   = 0
    MiddleButtonAreaLeft    = 0
    MiddleButtonAreaRight   = 0
    MiddleButtonAreaTop     = 0
    MiddleButtonAreaBottom  = 0

とりあえずタップの設定をしてみます.これでタップが出来るようになったら設定項目は当たりです.

$ synclient TapButton1=1
$ synclient -l|grep TapButton1
    TapButton1              = 1

設定項目が判ったら設定ファイルに書いておきます.
今回は /etc/X11/xorg.conf.d/21-apple-touchpad.conf にしました.
とりあえずタップの設定だけ以下のように設定しました.
ファイルの用意ができたらXの再起動を行います.awesomeの場合 Mod4 + Shift + q とかで一旦Xを終了してログインし直します.

Section "InputClass"
    Identifier "touchpad"
    Driver "synaptics"
    MatchIsTouchpad "on"
        Option "TapButton1" "1" # 1本指タップを左クリックに
EndSection

他の設定項目も同様に設定していきます.
現在こんな感じにしています.

Section "InputClass"
    Identifier "touchpad"
    Driver "synaptics"
    MatchIsTouchpad "on"
        Option "TapButton1" "1" # 1本指タップを左クリックに
        Option "TapButton2" "3" # 2本指タップを右クリックに
        Option "TapButton3" "2" # 3本指タップを中クリックに
        Option "VertTwoFingerScroll" "on"       # 縦スクロールを有効
        Option "HorizTwoFingerScroll" "on"      # 横スクロールを有効
        Option "PalmDetect" "1" # 手のひら検出
EndSection

今回Debian stretch testing amd64ですが他の環境でも同様に行けると思います.

$ screenfetch
         _,met$$$$$gg.           mk@x220
      ,g$$$$$$$$$$$$$$$P.        OS: Debian testing stretch
    ,g$$P""       """Y$$.".      Kernel: x86_64 Linux 4.5.0-2-amd64
   ,$$P'              `$$$.      Uptime: 1d 12h 8m
  ',$$P       ,ggs.     `$$b:    Packages: 4379
  `d$$'     ,$P"'   .    $$$     Shell: bash 4.3.42
   $$P      d$'     ,    $$P     Resolution: 1366x768
   $$:      $$.   -    ,d$$'     WM: Awesome
   $$\;      Y$b._   _,d$P'      WM Theme: awesome
   Y$$.    `.`"Y$$$$P"'          CPU: Intel Core i5-2540M CPU @ 3.3GHz
   `$$b      "-.__               GPU: Mesa DRI Intel(R) Sandybridge Mobile
    `Y$$                         RAM: 4288MiB / 15934MiB
     `Y$$.
       `$$b.
         `Y$$b.
            `"Y$b._
                `""""

]]>
https://matoken.org/blog/2016/06/17/to-set-the-apple-wireless-trackpad-at-awesomes/feed/ 0
画像や動画をtextに変換するhiptextを試す https://matoken.org/blog/2016/06/01/try-hiptext/ https://matoken.org/blog/2016/06/01/try-hiptext/#respond Wed, 01 Jun 2016 04:26:52 +0000 http://matoken.org/blog/?p=1376

類似のものでlibcacaとかがありますが,

Turn images into text better than caca/aalib

とのことでもっといいものらしいです.
Texttop[1]で使われているので興味を持ったのですが,そのままではBuild出来なかったのでメモです.

build

READMEではこの辺が必要とのことです.

sudo apt-get install build-essential libpng12-dev libjpeg-dev \
    libfreetype6-dev libgif-dev ragel libavformat-dev libavcodec-dev \
    libswscale-dev libgflags-dev libgoogle-glog-dev

Debian stretch testingではこんな感じ?

$ sudo apt-get install build-essential libpng-dev libjpeg-dev \
      libfreetype6-dev libgif-dev ragel libavformat-dev libavcodec-dev \
      libswscale-dev libgflags-dev libgoogle-glog-dev

後はmakeするだけなんですが,こんなエラーが.新しいlibavに追従できてない感じ?

g++ -g -O3 -std=c++11 -Wall -Wextra -fno-exceptions -fno-rtti -MD  -march=native -c -o movie.o movie.cc
movie.cc: In member function ‘void Movie::PrepareRGB(int, int)’:
movie.cc:56:42: error: ‘PIX_FMT_RGB24’ was not declared in this scope
                       width_, height_, PIX_FMT_RGB24, SWS_FAST_BILINEAR,
                                          ^
In file included from graphic.h:10:0,
                 from movie.h:9,
                 from movie.cc:4:
movie.cc:64:38: error: ‘avcodec_alloc_frame’ was not declared in this scope
 CHECK(frame_ = avcodec_alloc_frame());
                                      ^
movie.cc:66:19: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations]
   int rgb_bytes = avpicture_get_size(PIX_FMT_RGB24, width_, height_);
                   ^
In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:318:0,
                 from movie.cc:10:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4898:5: note: declared here
 int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
     ^
movie.cc:66:19: warning: ‘int avpicture_get_size(AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations]
   int rgb_bytes = avpicture_get_size(PIX_FMT_RGB24, width_, height_);
                   ^
In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:318:0,
                 from movie.cc:10:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4898:5: note: declared here
 int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
     ^
movie.cc:69:14: warning: ‘int avpicture_fill(AVPicture*, const uint8_t*, AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations]
   int prep = avpicture_fill(reinterpret_cast<AVPicture*>(frame_rgb_),
              ^
In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:318:0,
                 from movie.cc:10:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4883:5: note: declared here
 int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
     ^
movie.cc:69:14: warning: ‘int avpicture_fill(AVPicture*, const uint8_t*, AVPixelFormat, int, int)’ is deprecated [-Wdeprecated-declarations]
   int prep = avpicture_fill(reinterpret_cast<AVPicture*>(frame_rgb_),
              ^
In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:318:0,
                 from movie.cc:10:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4883:5: note: declared here
 int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
     ^
movie.cc: In member function ‘Graphic Movie::Next()’:
movie.cc:94:5: warning: ‘void av_free_packet(AVPacket*)’ is deprecated [-Wdeprecated-declarations]
     av_free_packet(&packet);
     ^
In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:318:0,
                 from movie.cc:10:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4040:6: note: declared here
 void av_free_packet(AVPacket *pkt);
      ^
movie.cc:94:5: warning: ‘void av_free_packet(AVPacket*)’ is deprecated [-Wdeprecated-declarations]
     av_free_packet(&packet);
     ^
In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:318:0,
                 from movie.cc:10:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4040:6: note: declared here
 void av_free_packet(AVPacket *pkt);
      ^
movie.cc:94:27: warning: ‘void av_free_packet(AVPacket*)’ is deprecated [-Wdeprecated-declarations]
     av_free_packet(&packet);
                           ^
In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:318:0,
                 from movie.cc:10:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4040:6: note: declared here
 void av_free_packet(AVPacket *pkt);
      ^
<ビルトイン>: ターゲット 'movie.o' のレシピで失敗しました
make: *** [movie.o] エラー 1

でも以下のPRを反映したら通りました :)

試してみる

サンプルとして,balls.jpg, obama.jpg があるのでこれを試してみます.
うまく動いていそうです.

47418

でも.pngはうまく動かない?

$ ./hiptext ~/Downloads/Tux.png
F0601 11:01:16.713266 30721 png.cc:35] Check failed: type == PNG_COLOR_TYPE_RGB || type == PNG_COLOR_TYPE_RGBA png bad type: /home/mk/Downloads/Tux.png
*** Check failure stack trace: ***
    @     0x7fa48d3c013d  google::LogMessage::Fail()
    @     0x7fa48d3c1fa3  google::LogMessage::SendToLog()
    @     0x7fa48d3bfccb  google::LogMessage::Flush()
    @     0x7fa48d3c298e  google::LogMessageFatal::~LogMessageFatal()
    @           0x41859f  LoadPNG()
    @           0x403fa8  main
    @     0x7fa489e59610  __libc_start_main
    @           0x40a229  _start
    @              (nil)  (unknown)
中止
$ convert ~/Downloads/Tux.png ./Tux.jpg
$ ./hiptext Tux.jpg

`.jpg`に変換したらいけてる感じですがなんか欠けてます.

26780171563 8d301b27a4

動画再生もいけます.再生のみで一時定位などの操作は出来ない感じ?

今のところlibcacaや動画ではvlcやmplayerなんかのほうがパッケージで導入できるのでお手軽そう.

とりあえず動くようになったので次はTexttopを試してみようと思います.

]]>
https://matoken.org/blog/2016/06/01/try-hiptext/feed/ 0